route.php与routemy.php短网址设置

本文由verycong发布于齐博X1官方论坛:

https://x1.php168.com/bbs/show-2418.html

由于官方开发新模块后总是会升级 route.php ,如果我们使用 route.lock 功能,那新模块的规则又需要我们手动去添加。

那是经过建议,官方升级了。

if (is_file(APP_PATH.'routemy.php')) { //用户自定义的路由规则

  1. include APP_PATH.'routemy.php';

}

也就是优先调用 routemy.php 的文件,

这个文件中的 规则会优先 route.php中的规则哦。

  1. <?php
  2. use think\Route;
  3. Route::group(['name'=>'yuanliao','ext'=>'html'], [
  4. 'show-$' =>['yuanliao/content/show',['method'=>'get'],['id' => '\d+']],
  5. 'list-'=>['yuanliao/content/index',['method'=>'get'],['fid' => '\d+']],
  6. 'mid-$'=>['yuanliao/content/index',['method'=>'get'],['mid' => '\d+']],
  7. 'show' => 'yuanliao/content/show',
  8. 'list' => 'yuanliao/content/index',
  9. 'index' => 'yuanliao/index/index',
  10. ]);
  11. /*测试优先*/
  12. Route::group(['name'=>'info','ext'=>'html'], [
  13. 'show-$' =>['cms/content/show',['method'=>'get'],['id' => '\d+']],
  14. 'list-'=>['cms/content/index',['method'=>'get'],['fid' => '\d+']],
  15. 'mid-$'=>['cms/content/index',['method'=>'get'],['mid' => '\d+']],
  16. 'show' => 'cms/content/show',
  17. 'list' => 'cms/content/index',
  18. 'index' => 'cms/index/index',
  19. ]);
  20. Route::group(['name'=>'goodurl','ext'=>'html'], [
  21. 'show-$' =>['goodurl/content/show',['method'=>'get'],['id' => '\d+']],
  22. 'list-'=>['goodurl/content/index',['method'=>'get'],['fid' => '\d+']],
  23. 'mid-$'=>['goodurl/content/index',['method'=>'get'],['mid' => '\d+']],
  24. 'show' => 'goodurl/content/show',
  25. 'list' => 'goodurl/content/index',
  26. 'index' => 'goodurl/index/index',
  27. ]);

默认应该是没有 routemy.php文件的,

所以请大家可以自己新建一个(别用记事本哦),复制的模块,什么的,都可以放在这个规则文件中。

以后官方升级了route.php并不会更改你的规则了。