阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

LNMP 下添加 Discuz x2.5 的伪静态规则

194次阅读
没有评论

共计 2281 个字符,预计需要花费 6 分钟才能阅读完成。

今天一个找我配置过 lnmp 环境的用户要搭建 Discuz 论坛,但是发现不支持伪静态,站长没怎么折腾过 Discuz,百度下才知道,原来军哥的 LNMP 环境包自带的 DZ 规则不适用于 Discuz x2.5,记录下对应的伪静态规则。

打开 LNMP 伪静态文件目录:

1
cd /usr/local/nginx/conf

新建并编辑 discuzx25.conf 文件:

1
vi discuzx25.conf

按 i 进入编辑模式,添加下面的代码:

12
3
4
5
6
7
8
9
10
1112
rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;
rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;
rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;
rewrite ^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/index.php?action=$2&value=$3 last;
rewrite ^([^\.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3 last;
if (!-e $request_filename) {
        return 404;
}

按 Esc 退出编辑模式,输入 :wq 保存退出。

然后进入网站配置文件目录:

1
cd /usr/local/nginx/conf/vhost

编辑对应的网站配置文件,比如 aaa.com.conf

1
vi aaa.com.conf

找到配置中的

1
include discuz.conf;

修改为

1
include discuzx25.conf;

保存后,重启 Nginx 或 LNMP:

1
lnmp restart

注:以上是 lnmp 1.2 下的操作。

方法出自:http://www.gongzi.org/lnmp-discuzx25-rewrite.html

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-01-22发表,共计2281字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中