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,就全部只能用路由模式了。