This article introduces to you the URL access mode in TP5. It has certain reference value. Friends in need can refer to it.
1. PATH_INFO
Turn off routing, find url_route_must (default is false) in application/config.php, and set it to false. After routing is closed, no routing rules will be parsed, and the default PATH_INFO mode will be used to access the URL:
2. Mixed mode
Turn on routing and use a mixture of the default PATH_INFO methods for routing definition:
'url_route_on' => true, 'url_route_must'=> false,
Under this method, you only need to define routing rules for the access addresses that need to be defined, and the rest still follow the first normal mode PATH_INFO mode. Visit URL.
3. Force the use of routing mode
Find the following setting item in application/config.php and set it to true
'url_route_on' => true, 'url_route_must' => true,
In application/route.php Comment
return [ '__pattern__' => [ 'name' => '\w+', ], '[hello]' => [ ':id' => ['index/hello', ['method' => 'get'], ['id' => '\d+']], ':name' => ['index/hello', ['method' => 'post']], ], ];
and add the code
use think\Route; Route::rule("hello", "test/Test/hello");
Related recommendations:
PHP’s operating mechanism and working principle
The above is the detailed content of Parsing of URL access patterns in TP5. For more information, please follow other related articles on the PHP Chinese website!