thinkphp5 怎么设置全局路由

 时间:2024-10-26 10:05:58

1、一牡啾锯辏种是在application/route.php中配置:示例:return [ '__pattern__' => [ 'na罪焐芡拂me' => '\w+', ], '[hello]' => [ ':id'=> ['index/hello', ['method' => 'get'], ['id' => '\d+']], ':name' => ['index/hello', ['method'=> 'post']], ],];

2、一牡啾锯辏种是动态注册:示例:把route.php中官方配置的代码删掉,然后写如下代码:use think\Route;Route::rule(‘hello’,’sample/test/hello’);

3、注意:对某个方法进行动态注册路由之后,之前的pathinfo模式就失效了,只是对当前这个方法失效,其它方法还是可以正常使用pathinfo。

4、也可以在配置文件中设置强制使用路由模式,在application\config.php中找到。

5、‘url_route_must’设置为true,就全部只能用路由模式了。

  • Xshell6怎么设置最后一个标签关闭时退出xshell
  • react 的初次安装和启动方法
  • WebStorm(Mac版)配置微信小程序开发
  • Intellij IDEA 中无法编译lombok的解决方法
  • Mac OS X系统XAMPP安装教程
  • 热门搜索
    科学小常识手抄报 诚信从我做起手抄报 孝心少年手抄报 关于春节手抄报大全 手抄报标题设计 爱国主义手抄报内容 创卫手抄报设计图 节约水资源手抄报 科技之光手抄报内容 一年级感恩手抄报