iis服务器助手广告广告
返回顶部
首页 > 资讯 > 后端开发 > PHP编程 >phpcms在nginx的rewrite伪静态标准写法
  • 192
分享到

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

phpcmsrewrite伪静态 2022-06-12 01:06:05 192人浏览 安东尼
摘要

我用的lnmp一键安装包,conf文件是放在默认路径。在进行测试时,我先使用了 复制代码代码如下: location / { rewrite ^/caipu-([0-9]+)-([0-9]+)-([0-9]+).html

我用的lnmp一键安装包,conf文件是放在默认路径。在进行测试时,我先使用了


复制代码代码如下:

location / {

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

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

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

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

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

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

}

然后就出现杯具了。打开网站首页时提示“Action does not exist.”意思是行为不存在?我翻遍了百度,在phpcms官方论坛有人说这个错误是地址问题,再联想到我是修改伪静态出现的······我懂了,是首页伪静态问题!

在我对照了Wordpress官方的写法后,我TM终于写成了。。。


复制代码代码如下:

location / {

if (!-f $request_filename){

rewrite (.*) /index.php;

}

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

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

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

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

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

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

}

--结束END--

本文标题: phpcms在nginx的rewrite伪静态标准写法

本文链接: https://www.lsjlt.com/news/31674.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作