找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 98|回复: 0

[cms教程] phpcms在nginx的rewrite伪静态标准写法

[复制链接]

该用户从未签到

发表于 2019-3-24 16:10:00 | 显示全部楼层 |阅读模式

您需要 登录 才可以下载或查看,没有账号?立即注册

×
phpcms在nginx的rewrite伪静态标准写法
我用的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;
}
回复

使用道具 举报

网站地图|页面地图|文字地图|Archiver|手机版|小黑屋|找资源 |网站地图

GMT+8, 2024-10-5 13:29

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表