Apache
httpd.conf
Themod_rewrite.so
module is loaded in the configuration fileAllowOverride None
Will beNone
changed toAll
- 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/$1 [QSA,PT,L] </IfModule>
IIS
If your server environment supports ISAPI_Rewrite
it, you can configure the httpd.ini
file and add the following content:
RewriteRule (.*)$ /index\.php\?s=$1 [I]
It can be configured under the higher version of IIS web.Config
, adding rewrite
nodes 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 the lower version of Nginx, PATHINFO is not supported, but it can be achieved by Nginx.conf
configuring forwarding rules in:
location / { // …..省略部分代码
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
}
}
In fact, it is forwarded internally to the compatible URL provided by ThinkPHP. In this way, other WEB server environments that do not support PATHINFO can be solved.
If your application is installed in a secondary directory, Nginx
the pseudo-static method is set as follows, where youdomain
is the name of the directory.
location /youdomain/ {
if (!-e $request_filename){
rewrite ^/youdomain/(.*)$ /youdomain/index.php?s=/$1 last;
}
}
Original access URL:
http://serverName/index.php/模块/控制器/操作/[参数名/参数值...]
After setting, we can access in the following way:
http://serverName/模块/控制器/操作/[参数名/参数值...]