URL access process in the framework
URL Design Specification
6.0 URL access is affected by routing, if it is not defined or matched In the case of routing (and if the forced routing mode is not turned on), it is based on:
http://serverName/index.php(或者其它入口文件)/控制器/操作/参数/值…
If the automatic multi-application mode is turned on, the URL is generally
http://serverName/index.php/应用/控制器/操作/参数/值...
The URL access in normal mode is no longer Supported, but parameters can support passing values in the normal way
If the server does not support PATHINFO, you can use the compatibility mode to access the following:
http://serverName/index.php?s=/控制器/操作/[参数名/参数值...]
URL rewriting rules
You can hide the application's entry file index.php through URL rewriting (it can also be other entry files, but URL rewriting usually can only set one entry file). The following is the configuration reference of the relevant server:
[Apache]
1. The mod_rewrite.so module is loaded in the httpd.conf configuration file
2.AllowOverride None Change None to All
3. Save the following content as a .htaccess file and place it in the same directory as the application entry file
<IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/ [QSA,PT,L] </IfModule>
[IIS](windows)
If your server environment supports ISAPI_Rewrite, you can configure the httpd.ini file and add the following content:
RewriteRule (.*)$ /index\.php\?s= [I]
You can configure web under higher versions of IIS. Config, add rewrite node in the middle:
<rewrite> <rules> <rule name="OrgPage" stopProcessing="true"> <match url="^(.*)$" /> <conditions logicalGrouping="MatchAll"> <add input="{HTTP_HOST}" pattern="^(.*)$" /> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> </conditions> <action type="Rewrite" url="index.php/{R:1}" /> </rule> </rules> </rewrite>
[ Nginx ]
In lower versions of Nginx, PATHINFO is not supported, but it can be achieved by configuring forwarding rules in Nginx.conf:
location / { // …..省略部分代码 if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/ last; } }
In fact, it is forwarded to ThinkPHP internally The provided compatible URL can be used to solve other WEB server environments that do not support PATHINFO.