ThinkPHP在不同系统下的伪静态规则汇总

一、在Nginx下的伪静态规则,一般命名Nginx.conf

location / {
   if (!-e $request_filename) {
   rewrite  ^(.*)$  /index.php?s=/$1  last;
   break;
    }
 }


二、在Apache下的伪静态规则, 一般命名.htaccess

<IfModule mod_rewrite.c>
  Options +FollowSymlinks -Multiviews
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php?s=$1 [QSA,PT,L]
</IfModule>


三、在Windows的IIS下的伪静态规则,一般命名web.Config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="OrgPage" stopProcessing="true">
                    <match url="^(.*)$" ></match>
                    <conditions logicalGrouping="MatchAll">
                        <add input="{HTTP_HOST}" pattern="^(.*)$" ></add>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" ></add>
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" ></add>
                    </conditions>
                    <action type="Rewrite" url="index.php/{R:1}" ></action>
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>
posted @ 2024-03-23 08:26  隔壁老王_wdUV  阅读(335)  评论(0编辑  收藏  举报