The Access Mode and Path Access Mode of pathinfo in ThinkPHP and the Rewrite Summary of URL

  • 2021-07-16 02:07:59
  • OfStack

In this paper, the two modes of pathinfo, four path access modes and URL rewriting related knowledge are summarized and shared for everyone to query and learn from. It is summarized as follows:

1. pathinfo

Access the test method under module IndexAction. class. php

http://localhost/index.php?m=Index & a=test is equivalent to http://localhost/index. php/Index/test

2, 4 Path Access Modes

Modify the values of URL_MODEL under the config directory as follows:

A value of 0 is called normal mode. For example: http://localhost/index.php? m = Module & a = Method
A value of 1 is called pathinfo mode. For example: http://localhost/index. php/Module/Method
A value of 2 is called rewrite rewrite (pseudo static). You can write related rewrite rules by yourself, or you can hide index. php by using rewrite rules provided by the system, and 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 access format, all use pathinfo format. Then it will prompt you that the path format is incorrect. Then, you can handle it with the compatibility mode labeled 3. His path access is similar to 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 Replace None with All

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

(4) Put the. htaccess file in the same level directory of the entry file

Rewriting with URL is beneficial to seo, but it will increase the performance consumption of the server.

I hope this article is helpful to everyone's ThinkPHP programming.


Related articles: