在nginx的相关网站配置中,引入这个伪静态规则文件就可以了。
比如:
// 在 nginx/nginx.conf的server{}中引入 .htaccess 文件:
include /data/wwwroot/phpcms/.htaccess;
但事情到这里并没有完成。因为Apache下的伪静态规则,跟nginx下的并不一样。所以需要对原默认的规则写法进行修改。
如phpcms提供的原始.htaccess文件是这样的:
RewriteEngine on
RewriteRule ^content-([0-9]+)-([0-9]+)-([0-9]+).html index.php?m=content&c=index&a=show&catid=$1&id=$2&page=$3
在nginx下,要去掉第一行的RewriteEngine on。然后,RewriteRule要改成rewrite,后面则要加上分号结束。变成这样:
rewrite ^content-([0-9]+)-([0-9]+)-([0-9]+).html index.php?m=content&c=index&a=show&catid=$1&id=$2&page=$3 last;
1
总结,只要在nginx中引入这个文件,就可以由网站管理员随时添加修改伪静态规则了。