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

Source: Internet
Author: User
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.

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: info-contact@alibabacloud.com 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.