Summary of pathinfo access mode, path access mode, and URL rewriting in ThinkPHP. thinkphppathinfo_PHP tutorial

Source: Internet
Author: User
Summary of pathinfo access mode, path access mode, and URL rewriting in ThinkPHP, thinkphppathinfo. Summary of pathinfo access mode, path access mode, and URL rewriting in ThinkPHP, thinkphppathinfo this article provides a summary of the pathinfo access mode, path access mode, and URL rewriting modes in ThinkPHP based on the two pathinfo modes, four path access modes, and URL rewriting modes in ThinkPHP. thinkphppathinfo

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.

ThinkPHP url path access mode problems

It can be obtained using $ _ GET.
For example
Index. php/action/function/id/2

$ _ GET [cation] is the function

$ _ GET [id] is 2

Do you understand? The format is changed, and the value is the same.

Thinkphp's four URL modes differ in url access, not to mention those functions such as URL rewriting.

Localhost/think/index. php/Index/index is a pseudo-static URL address, in order to make the page better captured by the search engine. Search engines are better than static pages. what is another feature of dynamic pages? So you can remove it.

Localhost/... = index is the most primitive access method. A typical dynamic webpage URL. Unfriendly to search engines.

Localhost/think/index. php/Index/index? Id = 1 is a pseudo-static compatibility statement. Some servers do not support pseudo-static data writing.

You have not proposed another method: localhost/think/index/Index/index. It is the rewrite function of apache and needs to enable the rewrite module. However, some servers are not enabled, and enabling it will increase the server's resource consumption.

Conclusion: you can use the extension of static pages such as .html#.htm to improve the pseudo-static performance. the TP framework has such a function.

Note: rewrite is also a pseudo-static one.

This document describes two pathinfo modes, four path access modes, and URL rewriting in ThinkPHP...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.