phpcms在nginx的rewrite伪静态标准写法
发布时间:2012-09-24 11:51:10 作者:佚名
我要评论
phpcms在nginx的rewrite伪静态写法,网上是乱七八糟的不知道有多少种。有的是直接从apache的规则修改来的,但这种修改而来的却不是最标准的
我用的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;
}
复制代码
代码如下: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;
}
相关文章
完美解决phpcms图片太大撑破表格图片自适应图片按比例缩小
下面小编就为大家带来一篇完美解决phpcms图片太大撑破表格图片自适应图片按比例缩小。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧2016-10-18- 这篇文章主要介绍了PHPCMS v9 安全设置、防范教程,需要的朋友可以参考下2016-09-05
PHPCMS V9 全站 Sitemaps生成实现代码[服务器端版]
这篇文章主要介绍了PHPCMS V9 全站 Sitemaps生成实现代码[服务器端版],需要的朋友可以参考下2016-06-08- 这篇文章主要介绍了phpcms内容详情页只显示日期不显示时间的方法,即格式化时间输出的方法,需要的朋友可以参考下2015-06-19
- 这篇文章主要介绍了PHPCMS制作网站地图的简单方法,本文给出了操作步骤及标签源码,需要的朋友可以参考下2015-06-19
- 这篇文章主要介绍了PHPCMSV9父栏目调用子栏目的方法,本文讲解了在二级栏目列表页调用、在一级栏目列表页调用两种方法方式,需要的朋友可以参考下2015-06-19
- 这篇文章主要介绍了PHPCMS使用date函数实现自动更新页脚年月的方法,本文主要还是可以学习到date函数的用法了,需要的朋友可以参考下2015-06-19
- 这篇文章主要介绍了phpsso忘记密码的解决办法,本文用PHPCMS的密码及encrypt值替换数据表解决了这个问题,方法还是挺靠谱的,只是操作要求有点,需要的朋友可以参考下2015-06-19
- 这篇文章主要介绍了phpcms 退出无法同步通知discuz问题的解决方法,需要的朋友可以参考下2014-12-15
phpcms v9列表页如何调用子栏目如首页>产品中心>产品类型a
phpcms v9列表页如何调用子栏目如:首页>产品中心>产品类型a>产品类型a11,在列表页产品类型a中,包括产品类型a1、产品类型a2、产品类型a32014-09-24


最新评论