1. PATH_INFO
关闭路由,在application/config.php中找到url_route_must(默认为false),设置为false。路由关闭后,不会解析任何路由规则,采用默认的PATH_INFO模式访问URL:
2. 混合模式
开启路由,并使用路由定义+默认PATH_INFO方式的混合:'url_route_on' => true,'url_route_must'=> false,
该方式下面,只需要对需要定义路由规则的访问地址定义路由规则,其它的仍然按照第一种普通模式的PATH_INFO模式访问URL。
3. 强制使用路由模式
在application/config.php中找到以下设置项,设置为true'url_route_on' => true,'url_route_must' => true,
在application/route.php中将
return [ '__pattern__' => [ 'name' => '\w+', ], '[hello]' => [ ':id' => ['index/hello', ['method' => 'get'], ['id' => '\d+']], ':name' => ['index/hello', ['method' => 'post']], ],];
注释,并添加代码
use think\Route;Route::rule("hello", "test/Test/hello");
注意!!当对一个方法进行路由定义时不可对同一个方法进行PATH_INFO访问,反之亦然