隐藏PHP后缀
效果:形如 /test.php?itemid=1 的网址变为 /test?itemid=1
1、添加伪静态规则
Apache
RewriteRule ^(.*)/([a-z_\-]+)$ $1/$2.php RewriteRule ^(.*)/([a-z_\-]+)\?(.*)$ $1/$2.php?$3
Nigix
rewrite ^/(.*)/([a-z_\-]+)$ /$1/$2.php last; rewrite ^/([a-z_\-]+)\?(.*)$ /$1/$2.php?$3 last;
IIS
<rule name="destoon_rewrite_ext_1">
<match url="^(.*)/([a-z_\-]+)$" />
<action type="Rewrite" url="{R:1}/{R:2}.php" />
</rule>
<rule name="destoon_rewrite_ext_2">
<match url="^(.*)/([a-z_\-]+)\?(.*)$" />
<action type="Rewrite" url="{R:1}/{R:2}.php{R:3}" />
</rule>2、以上伪静态规则仅供参考,测试运行正常后,修改根目录config.inc.php里 $CFG['ext'] = '.php'; 为 $CFG['ext'] = '';
修改PHP后缀
效果:形如 /test.php?itemid=1 的网址变为 /test.xyz?itemid=1
1、添加伪静态规则
Apache
RewriteRule ^(.*)\.xyz(.*)$ $1.php$2
Nigix
rewrite ^/(.*)\.xyz(.*)$ /$1.php$2 last;
IIS
<rule name="destoon_rewrite_ext_0">
<match url="^(.*)\.xyz(.*)$" />
<action type="Rewrite" url="{R:1}.php{R:2}" />
</rule>2、以上伪静态规则仅供参考,测试运行正常后,修改根目录config.inc.php里 $CFG['ext'] = '.php'; 为 $CFG['ext'] = '.xyz';
如果修改的后缀不为xyz,请按实际修改,为了不和已有文件冲突,不建议使用已经存在的文件的后缀,例如htm,html,js,css,png等。






