bbs.thinkzhu.com

?找回密码
?立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 3369|回复: 0
打印 上一主题 下一主题

Linux环境下Discuz论坛nginx伪静态规则设置

[复制链接]

170

主题

267

帖子

1539

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1539
跳转到指定楼层
楼主
发表于 2014-9-11 11:01:52 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

在相应nginx配置文件的server中,添加如下代码

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;if (!-e $request_filename) {return 404;}

系统运维 温馨提醒:qihang01原创内容版权所有,转载请注明出处及原文链接

例如:
vi /usr/local/nginx/conf/nginx.conf #编辑nginx配置文件
找到下面这行,在server_name localhost;后边一行添加上面的代码

server { listen 80; server_name localhost;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;if (!-e $request_filename) {return 404;} #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.php index.html index.htm; }

保存配置文件,最后重启nginx即可
service nginx restart


您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|bbs.thinkzhu.com ( 京ICP备14043241号 )

Powered by Discuz! X3.4?? 2001-2012 Comsenz Inc.

GMT+8, 2019-10-4 11:34ag网投出|官网 , Processed in 0.049959 second(s), 25 queries .

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