## zzzphp的伪静态规则如下: php常见的三种环境Nginx,IIS,Apache伪静态规则不同,一般如果在后台开启伪静态会直接弹窗显示,复制粘贴到配置文件中对应位置即可。 一、Nginx配置 > 1.一般ECS服务器搭建环境或宝塔搭建环境Nginx居多,可以直接在宝塔面板直接设置规则。 > 2.后台无法直接设置,只能去配置文件位置添加。 ``` rewrite ^/wap$ /wap/index.php; rewrite ^/wap/([a-z0-9-]*)/$ /wap/$1/; rewrite ^/wap/([A-Za-z0-9-]*).([a-z]*)$ /wap/?$1.$2; rewrite ^/wap/([A-Za-z0-9-]*)_([0-9]*).([a-z]*)$ /wap/?$1_$2.$3; rewrite ^/wap/([A-Za-z0-9-]*)/([0-9]*).([a-z]*)$ /wap/?$1/$2.$3; rewrite ^/wap/([A-Za-z0-9-]*)/([0-9]*)_([0-9]*).([a-z]*)$ /wap/?$1/$2_$3.$4; rewrite ^/$ /index.php; rewrite ^/([A-Z].*)$ /?$1; rewrite ^/brandlist/([A-Za-z0-9-]*)$ /?brandlist/$1; rewrite ^/([A-Za-z0-9-]*)_([0-9]*).([a-z]*)$ /?$1_$2.$3; rewrite ^/([A-Za-z0-9-]*)/([0-9]*).([a-z]*)$ /?$1/$2.$3; rewrite ^/([A-Za-z0-9-]*)/([0-9]*)_([0-9]*).([a-z]*)$ /?$1/$2_$3.$4; ``` 二、IIS配置 > 1.iis一般情况是在网站根目录中会自动创建一个web.config,打开替换对应位置。 > 2.如果没有设置伪静态会自动创建此文件,无需修改。 ``` <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <!--start-rewrite--> <rewrite> <rules> <!--WAP首页--> <rule name="WapIndex"> <match url="^$wap" /> <action type="Rewrite" url="/wap/index.php" /> </rule> <!--通用--> <rule name="Wapurl"> <match url="^wap/([a-z0-9-]*)/$" /> <action type="Rewrite" url="/wap/{R:1}/" /> </rule> <!--通用--> <rule name="Wapsort"> <match url="^wap/([A-Za-z0-9-]*)siteext$" /> <action type="Rewrite" url="/wap/?{R:1}siteext" /> </rule> <rule name="Wapsorts"> <match url="^wap/([A-Za-z0-9-]*)_([0-9]*)siteext$" /> <action type="Rewrite" url="/wap/?{R:1}_{R:2}siteext" /> </rule> <!--通用--> <rule name="Wapcontent"> <match url="^wap/(about|brand|content|list|brandlist|taglist|gbook)/([^\s]+)$" /> <action type="Rewrite" url="/wap/?{R:1}/{R:2}" /> </rule> <!--分页--> <rule name="Waplist"> <match url="^wap/([A-Za-z0-9-]*)/([0-9]*)_([0-9]*)siteext$" /> <action type="Rewrite" url="/wap/?{R:1}/{R:2}_{R:3}siteext" /> </rule> <!--PC首页--> <rule name="Index"> <match url="^$" /> <action type="Rewrite" url="index.php" /> </rule> <!--通用--> <rule name="url"> <match url="^([a-z0-9-]*)/$" /> <action type="Rewrite" url="/{R:1}/" /> </rule> <!--通用--> <rule name="sort"> <match url="^([A-Za-z0-9-]*)siteext$" /> <action type="Rewrite" url="/?{R:1}siteext" /> </rule> <rule name="sorts"> <match url="^([A-Za-z0-9-]*)_([0-9]*)siteext$" /> <action type="Rewrite" url="/?{R:1}_{R:2}siteext" /> </rule> <!--通用--> <rule name="content"> <match url="^(about|brand|content|list|brandlist|taglist|gbook)/([^\s]+)$" /> <action type="Rewrite" url="/?{R:1}/{R:2}" /> </rule> <!--分页--> <rule name="list"> <match url="^([A-Za-z0-9-]*)/([0-9]*)_([0-9]*)siteext$" /> <action type="Rewrite" url="/?{R:1}/{R:2}_{R:3}siteext" /> </rule> </rules> </rewrite> <!--end-rewrite--> </system.webServer> </configuration> ``` 三、Apache环境 > 1.一般根目录有.htaccess文件,打开直接修改。 > 2.阿里云linux虚拟主机,默认是Apache环境,后台设置伪静态会自动创建,无需修改。 > 3.宝塔等环境可复制规则粘贴进去即可。 ``` RewriteEngine On RewriteRule ^wap$ /wap/index.php RewriteRule ^wap/([a-z0-9-]*)/$ /wap/$1/ RewriteRule ^wap/([A-Za-z0-9-]*)_([0-9]*).([a-z]*)$ /wap/?$1_$2.$3 RewriteRule ^wap/([A-Za-z0-9-]*)/([0-9]*).([a-z]*)$ /wap/?$1/$2.$3 RewriteRule ^wap/([A-Za-z0-9-]*)/([0-9]*)_([0-9]*).([a-z]*)$ /wap/?$1/$2_$3.$4 RewriteRule ^$ index.php RewriteRule ^([A-Z].*)$ /?$1 RewriteRule ^brandlist/([A-Za-z0-9-]*)$ /?brandlist/$1 RewriteRule ^([A-Za-z0-9-]*)_([0-9]*).([a-z]*)$ /?$1_$2.$3 RewriteRule ^([A-Za-z0-9-]*)/([0-9]*).([a-z]*)$ /?$1/$2.$3 RewriteRule ^([A-Za-z0-9-]*)/([0-9]*)_([0-9]*).([a-z]*)$ /?$1/$2_$3.$4 ```