PathInfo access mode, path access pattern and URL Rewrite summary _php instance in thinkphp

Source: Internet
Author: User

This paper summarizes the two modes of pathinfo in thinkphp, four path access modes and URL rewriting related knowledge, and shares them for easy inquiry and 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 equal to Http://localhost/index.php/Index/test

2, four kinds of path access mode

At the bottom of the Config directory to make changes to the value of the Url_model, respectively, expressed as follows:

A value of 0 is called normal mode. such as: http://localhost/index.php?m= module &a= method
A value of 1 is called PathInfo mode. such as: http://localhost/index.php/module/method
A value of 2 is called rewrite rewrite (pseudo static) can write the relevant rewrite rules, or you can use the system for the rewrite rules we provide to hide the index.php, generate: http://localhost/module/method
A value of 3 is called compatibility mode. When the PathInfo mode is not supported on the server, but you are in the previous path access format, all using the PathInfo format. Then it will prompt you that the path format is not correct. Then, you can use the compatibility mode labeled 3 to deal with. 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 the Apache server

(2), allowoverride none change none to all

(3) Ensure that the Url_model is set to 2 in the config.php configuration file

(4), put the. htaccess file in the same level as the entry file

URL rewriting is advantageous for SEO, but it will increase the performance consumption of the server.

I hope this article will help you to thinkphp program design.

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.