## 偽靜態規則
這里提供的是常見的偽靜態規則,是ThinkPHP系統默認通用的規則。
建議使用LAMP、LNMP、LNAMP,IIS不太推薦,運行效率相比要低一點
IIS低版本,httpd.ini
~~~
RewriteRule (.*)$ /index\.php\?s=$1 [I]
~~~
IIS6,如果使用的是ISAPI_Rewrite3(完全破解版),則可以直接使用下面apache的.htaccess規則IIS高版本,web.Config,在中間添加rewrite節點
~~~
<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>
~~~
## IIS7/IIS8 web.config 規則
~~~
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="ThinkPHP_NiPaiYi" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/{R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
~~~
## Apache 規則
~~~
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
~~~
或者:(上面不能用可嘗試這個)
~~~
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?s=$1 [QSA,PT,L]
</IfModule>
~~~
## Nginx 規則
~~~
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
~~~
或者:(上面不能用可嘗試這個)
~~~
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
~~~
附上我的nginx配置圖,紅圈部分是我添加的。請參考自己主機對應的conf文件進行修改
