thinkphp pathinfo access mode, path access mode and URL rewrite summary, thinkphppathinfo
This paper summarizes the two modes of pathinfo in thinkphp, four kinds of path access modes and URL rewriting, and shares them for easy reference. The specific summary is as follows:
1, PathInfo
Access the test method below the module IndexAction.class.php
Http://localhost/index.php?m=Index&a=test equivalent to Http://localhost/index.php/Index/test
2. Four Path access modes
In the config directory below to make changes to the value of Url_model, respectively, the following:
A value of 0 is called normal mode. Example: Http://localhost/index.php?m= module &a= method
A value of 1 is called PathInfo mode. Example: http://localhost/index.php/module/method
A value of 2 is called rewrite rewrite (pseudo-static) can write its own related rewrite rules, you can also use the system to provide us with rewrite rules to hide index.php, Generate: http://localhost/module/method
A value of 3 is called compatibility mode. When the server does not support PathInfo mode, but you are in the previous path to access the format above, all in the pathinfo format. Then it will prompt you to format the path incorrectly. Then, you can use the label 3 compatibility mode to handle. His path access is similar to the Http://localhost/index.php?s= module/method
3. URL Rewrite steps:
(1), D:\wamp\wamp\Apache2\conf\httpd.conf Open the Url_rewrite module in Apache server
(2), allowoverride none change none to all
(3), make sure Url_model in config.php configuration file is set to 2
(4). Place the. htaccess file in the same sibling directory as the portal file
Using URL rewriting is good for SEO, but it will increase the performance consumption of the server.
I hope this article is helpful to everyone thinkphp program design.
thinkphp URL path Access Pattern related issues
It can be obtained with $_get.
As an example,
Index.php/action/function/id/2
$_get[cation] is function
$_get[id] is 2
Do you understand me? It's just a change of form, a value that can be taken.
thinkphp 4 URL patterns are different in URL access, not to mention that the URL rewrite and other work can
localhost/think/index.php/index/index This one is a pseudo-static URL address, in order to make the page better crawled by the search engine. Search engine prefers static page, dynamic page Another feature is to have a number, so write it off.
Localhost/...=index This one is the most primitive method of access. A typical Dynamic Web page URL address. Unfriendly to search engines.
Localhost/think/index.php/index/index?id=1 This is a pseudo-static compatibility notation. Some servers do not support pseudo-static, so write this.
There's another way you didn't mention it: Localhost/think/index/index/index. He is an Apache rewrite feature that requires the rewrite module to be turned on. However, some servers do not open and will increase the resource consumption of the server.
Summary: You can add a. html or an. htm extension to a static page after pseudo-static, to make the pseudo-static more perfect, the TP framework has such a function that you study under.
Note: Rewrite is actually a pseudo-static one.
http://www.bkjia.com/PHPjc/868228.html www.bkjia.com true http://www.bkjia.com/PHPjc/868228.html techarticle thinkphp pathinfo in the access mode, path access mode and URL rewrite summary, thinkphppathinfo This article for thinkphp in the two modes of PathInfo, four path access mode and URL rewrite related ...