花使 發表於 2023-8-7 00:00:00

phpcms在nginx的rewrite伪静态标准写法

<p>
<span>我用的lnmp一键安装包,conf文件是放在默认路径。在进行测试时,我先使用了 </span></p>
<div>
<p>
<span><u>复制代码</u></span></p>
<p>
代码如下:</p>
</div>
<p>
<br>
location / { <br>
rewrite ^/caipu-(+)-(+)-(+).html /index.php?m=content&amp;c=index&amp;a=show&amp;catid=$1&amp;id=$2&amp;page=$3 last; <br>
rewrite ^/content-(+)-(+)-(+).html /index.php?m=content&amp;c=index&amp;a=show&amp;catid=$1&amp;id=$2&amp;page=$3 last; <br>
rewrite ^/list-(+)-(+).html /index.php?m=content&amp;c=index&amp;a=lists&amp;catid=$1&amp;page=$2 last; <br>
rewrite ^/tag-([^\.]*)-(+)-(+).html /index.php?m=content&amp;c=tag&amp;catid=$2&amp;tag=$1&amp;page=$3 last; <br>
rewrite ^/comment-(+)-(+)-(+).html /index.php?m=comment&amp;c=index&amp;a=init&amp;commentid=content_$1-$2-$3 last; <br>
rewrite ^/([^\.]*).html /index.php?m=member&amp;c=index&amp;a=$1 last; <br>
} </p>
<p>
<br><span>然后就出现杯具了。打开网站首页时提示“Action does not exist.”意思是行为不存在?我翻遍了百度,在phpcms官方论坛有人说这个错误是地址问题,再联想到我是修改伪静态出现的······我懂了,是首页伪静态问题! </span><br><br><span>在我对照了wordpress官方的写法后,我TM终于写成了。。。 </span></p>
<div>
<p>
<span><u>复制代码</u></span></p>
<p>
代码如下:</p>
</div>
<p>
<br>
location / { <br>
if (!-f $request_filename){ <br>
rewrite (.*) /index.php; <br>
} <br>
rewrite ^/caipu-(+)-(+)-(+).html /index.php?m=content&amp;c=index&amp;a=show&amp;catid=$1&amp;id=$2&amp;page=$3 last; <br>
rewrite ^/content-(+)-(+)-(+).html /index.php?m=content&amp;c=index&amp;a=show&amp;catid=$1&amp;id=$2&amp;page=$3 last; <br>
rewrite ^/list-(+)-(+).html /index.php?m=content&amp;c=index&amp;a=lists&amp;catid=$1&amp;page=$2 last; <br>
rewrite ^/tag-([^\.]*)-(+)-(+).html /index.php?m=content&amp;c=tag&amp;catid=$2&amp;tag=$1&amp;page=$3 last; <br>
rewrite ^/comment-(+)-(+)-(+).html /index.php?m=comment&amp;c=index&amp;a=init&amp;commentid=content_$1-$2-$3 last; <br>
rewrite ^/([^\.]*).html /index.php?m=member&amp;c=index&amp;a=$1 last; <br>
} </p>
頁: [1]
查看完整版本: phpcms在nginx的rewrite伪静态标准写法