This article mainly introduces the thinkPHP5.0 framework URL access method, specifically analyzes the URL path structure of the thinkPHP5.0 framework and common access methods, as well as the implementation of hidden entry files, the need for friends can refer to the following
This article describes the thinkPHP5.0 framework URL access method. Share to everyone for your reference, as follows:
URL Design
ThinkPHP5.0 A typical URL access rule without routing enabled is:
http://serverName/index.php (or other application entry file)/module/controller/operation/[parameter name/parameter value ...]
Support for switching to command-line access, if you switch to command-line mode, the following access rules are:
>php.exe index.php (or other application entrance file) module/controller/operation/[parameter name/parameter value ...]
As you can see, both URL Access and command-line access take the Path_info access address, where the path_info delimiter can be set.
Note: 5.0 The concept of URL mode is canceled, and normal mode URL access is no longer supported, if the server that does not support pathinfo can use compatibility mode to access the following:
http://serverName/index.php (or other application entry file)? s=/module/controller/operation/[parameter name/value ...]
When necessary, we can omit the module and controller inside the URL in some way.
URL case
By default, URLs are case-insensitive, which means that the module/controller/operation name inside the URL is automatically converted to lowercase, and the controller is converted to camel processing at the last call.
For example:
The http://localhost/index.php/Index/Blog/read//and the following access are equivalent Http://localhost/index.php/index/blog/read
If you access the following address
The http://localhost/index.php/Index/BlogTest/read//and the following access are equivalent Http://localhost/index.php/index/blogtest/read
In cases where this URL is case-insensitive, if you want to access the controller class for the Hump method, you need to use:
Http://localhost/index.php/Index/blog_test/read
If you want URL access to be case-sensitive, you can set it in the app configuration file:
Turn off automatic conversion of the controller and operation name in the URL ' Url_convert ' and false,
Once the automatic conversion is turned off, the controller name in the URL address becomes case sensitive, for example, the previous access address is written as:
Http://localhost/index.php/Index/BlogTest/read
However, the following URL access is still valid:
Http://localhost/index.php/Index/blog_test/read
The following URL access is not valid:
Http://localhost/index.php/Index/blogtest/read
Note: Routing addresses defined in a routing rule are defined by the actual name of the controller name (case-sensitive).
Hide the Portal file
In ThinkPHP5.0, the use of URL rewriting to hide the portal file is also supported by the optimized URL access principle, and the following example illustrates the settings for hiding the application portal file index.php.
The following is the Apache configuration process, you can refer to the following:
1. The mod_rewrite.so module is loaded in the httpd.conf configuration file
2. AllowOverride None Change None to all
3. Add the. htaccess file in the application Portal file sibling directory , with the following content:
<ifmodule mod_rewrite.c>options +followsymlinks-multiviewsrewriteengine onRewriteCond%{REQUEST_FILENAME}!- Drewritecond%{request_filename}!-frewriterule ^ (. *) $ index.php/$1 [qsa,pt,l]</ifmodule>