Tp5 configuration URL rewriting

Apache

  1. httpd.confThe mod_rewrite.somodule is loaded in the configuration file
  2. AllowOverride None Will be Nonechanged to All
  3. Save the following content as a .htaccessfile and place it in the same directory as the application entry file:
  4. <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_Rewriteit, you can configure the httpd.inifile and add the following content:

RewriteRule (.*)$ /index\.php\?s=$1 [I]

It can be configured under the higher version of IIS web.Config, adding rewritenodes 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.confconfiguring 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, Nginxthe pseudo-static method is set as follows, where youdomainis 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/模块/控制器/操作/[参数名/参数值...]

 

Guess you like

Origin blog.csdn.net/I_lost/article/details/105817245