官方升级后没有说明,那么,此建议由我提出,就由我来说明一下。
由于官方开发新模块后总是会升级 route.php ,如果我们使用 route.lock 功能,那新模块的规则又需要我们手动去添加。
那是经过建议,官方升级了。
if (is_file(APP_PATH.'routemy.php')) { //用户自定义的路由规则 include APP_PATH.'routemy.php'; }
也就是优先调用 routemy.php 的文件,
这个文件中的 规则会优先 route.php中的规则哦。
<?php use think\Route; Route::group(['name'=>'yuanliao','ext'=>'html'], [ 'show-<id>$' =>['yuanliao/content/show',['method'=>'get'],['id' => '\d+']], 'list-<fid>'=>['yuanliao/content/index',['method'=>'get'],['fid' => '\d+']], 'mid-<mid>$'=>['yuanliao/content/index',['method'=>'get'],['mid' => '\d+']], 'show' => 'yuanliao/content/show', 'list' => 'yuanliao/content/index', 'index' => 'yuanliao/index/index', ]); /*测试优先*/ Route::group(['name'=>'info','ext'=>'html'], [ 'show-<id>$' =>['cms/content/show',['method'=>'get'],['id' => '\d+']], 'list-<fid>'=>['cms/content/index',['method'=>'get'],['fid' => '\d+']], 'mid-<mid>$'=>['cms/content/index',['method'=>'get'],['mid' => '\d+']], 'show' => 'cms/content/show', 'list' => 'cms/content/index', 'index' => 'cms/index/index', ]); Route::group(['name'=>'goodurl','ext'=>'html'], [ 'show-<id>$' =>['goodurl/content/show',['method'=>'get'],['id' => '\d+']], 'list-<fid>'=>['goodurl/content/index',['method'=>'get'],['fid' => '\d+']], 'mid-<mid>$'=>['goodurl/content/index',['method'=>'get'],['mid' => '\d+']], 'show' => 'goodurl/content/show', 'list' => 'goodurl/content/index', 'index' => 'goodurl/index/index', ]);
默认应该是没有 routemy.php文件的,
所以请大家可以自己新建一个(别用记事本哦),复制的模块,什么的,都可以放在这个规则文件中。
以后官方升级了route.php并不会更改你的规则了。