Parsing of URL access patterns in TP5

不言
Release: 2023-04-03 10:32:01
Original
4865 people have browsed it

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:

Parsing of URL access patterns in TP5

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,
Copy after login

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,
Copy after login

In application/route.php Comment

return [
    '__pattern__' => [
        'name' => '\w+',
    ],
    '[hello]'     => [
        ':id'   => ['index/hello', ['method' => 'get'], ['id' => '\d+']],
        ':name' => ['index/hello', ['method' => 'post']],
    ],

];
Copy after login

and add the code

use think\Route;
Route::rule("hello", "test/Test/hello");
Copy after login

Parsing of URL access patterns in TP5

Related recommendations:

ThinkPHP5.X PHP5.6.27-nts and Apache use URL rewriting to hide the content of the entry file index.php

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!