This article mainly introduces the pathinfo access mode, path access mode, and URL rewriting summary in ThinkPHP. it is the basic knowledge of ThinkPHP route access and is very important in ThinkPHP development, for more information about ThinkPHP, see ThinkPHP.
This article summarizes the two pathinfo modes, four path access modes, and URL rewriting knowledge in ThinkPHP, and shares it with you for ease of query and reference. The details are summarized as follows:
1. pathinfo
Access the test method under the module IndexAction. class. php
Http: // localhost/index. php? M = Index & a = test is equivalent to http: // localhost/index. php/Index/test
2. Four path access modes
Modify the URL_MODEL value under the config directory as follows:
The value 0 is called the normal mode. For example, http: // localhost/index. php? M = Module & a = method
1 is called pathinfo mode. For example, http: // localhost/index. php/module/method
The value 2 is called rewrite (pseudo static). you can write related rewrite rules by yourself, or use the rewrite rules provided by the system to hide the index. php, generate: http: // localhost/module/method
The value 3 is called the compatibility mode. When the server does not support the pathinfo mode, but you use the pathinfo format in the previous path access format. Then it will prompt you that the path format is incorrect. Then, you can use the compatibility mode marked as 3. Its path access is similar to http: // localhost/index. php? S = module/method
3. URL rewriting steps:
(1), D: \ wamp \ Apache2 \ conf \ httpd. conf enable the URL_REWRITE module in the apache server
(2) change AllowOverride None to All
(3) make sure that the URL_MODEL in the config. php configuration file is set to 2.
(4) put the. htaccess file under the same directory of the entry file
Using URL rewriting is good for seo, but it will increase server performance consumption.
I hope this article will help you with ThinkPHP programming.