600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > nginx伪静态配置html php nginx配置伪静态

nginx伪静态配置html php nginx配置伪静态

时间:2021-11-27 18:52:02

相关推荐

nginx伪静态配置html php nginx配置伪静态

phpcms在nginx环境下默认的url规则太长,如果想把php文件伪静态成html文件,或者以/*结尾,就需要配置伪静态规则。

伪静态是一种可以把文件后缀改成任何可能的一种方法,下面给出了phpcms在nginx环境中伪静态的配置方法。

location / {

root /data/www;

index index.php index.html index.htm;

rewrite ^/phpcms/article/([0-9]+).html /phpcms/index.php?m=content&c=index&a=show&catid=6&id=$1 last;

rewrite ^/phpcms/caipu-([0-9]+)-([0-9]+)-([0-9]+).html /phpcms/index.php?m=content&c=index&a=show&catid=$1&id=$2&page=$3 last;

rewrite ^/phpcms/content-([0-9]+)-([0-9]+)-([0-9]+) /phpcms/index.php?m=content&c=index&a=show&catid=$1&id=$2&page=$3 last;

rewrite ^/phpcms/list-([0-9]+)-([0-9]+).html /phpcms/index.php?m=content&c=index&a=lists&catid=$1&page=$2 last;

rewrite ^/phpcms/tag-([^\.]*)-([0-9]+)-([0-9]+).html /phpcms/index.php?m=content&c=tag&catid=$2&tag=$1&page=$3 last;

rewrite ^/phpcms/comment-([0-9]+)-([0-9]+)-([0-9]+).html /phpcms/index.php?m=comment&c=index&a=init&commentid=content_$1-$2-$3 last;

rewrite ^/phpcms/([^\.]*).html /phpcms/index.php?m=member&c=index&a=$1 last;

}

以上是以phpcms做为二级目录为前提的配置方法,如果是一级目录作为根目录,只需将/phpcms去掉即可。本文是以phpcms为例来说明nginx环境里是如何配置伪静态的,其他情况类似。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。