企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## 伪静态规则 这里提供的是常见的伪静态规则,是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文件进行修改 ![](https://box.kancloud.cn/dfd37fca125d6154d410a4add1bff0a6_783x497.png)