当前位置: > Linux服务器 > nginx >

nginx下discuz! x2.5伪静态设置

时间:2014-09-14 02:22来源:linux.it.net.cn 作者:it

管理员登录到后台,选择“全局-SEO设置-URL静态化”,可以看到有“页面 标记 格式 可用”几个标题,将可用下面的方框里都选中,Rewrite兼容性选否,点击提交。
找到nginx配置文件中配置这个bbs域名的server段,在location /内添加伪静态规则。
比如原来是:

...
server {
    listen       80;
    server_name  www.aaa.com;
    access_log  /var/log/nginx/aaa.com.log  main;
    location / {
        root   /home/webroot;
        index  index.html index.htm index.php;
    }
}
...


修改后为:

...
server {
    listen       80;
    server_name  www.aaa.com;
    access_log  /var/log/nginx/aaa.com.log  main;
    location / {
        root   /home/webroot;
        index  index.html index.htm index.php;
        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;
        }
    }
}
...

 

(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容