TP 变更路由隐藏模块名称-隐藏路由


use think/Route;
//
获取路由 $path = request()->path(); $pathArr = explode('/', $path); // 过滤API admin 只针对 前端控制器啊的index if (!in_array($pathArr[0], ['api', 'admin']) && $pathArr[0] !== 'addons') { // 两种写法 一种是引入 use think\Route; 一种是不引入 Route::bind('index/index'); // \think\Route::bind('index/index'); }

这里简单解试下这段代码,意思是当我们的path/拆分后的第一段值不是apiadminaddons的时候绑定index模块

修改前:

http://haha.*******.top/index/indextype.html?id=1

修改后

http://haha.*******.top/type.html?id=1

tp5