Linux环境下Discuz! X2论坛nginx伪静态规则设置-linux安全运维_跨零代码

跨零代码为大家提供高品质的运维解决方案,请大家多多来访,跨零不胜感激,在此谢过。

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; }

案例:

[root@tiejiang ~]# vim /usr/local/nginx/conf/nginx.conf

找到下面这行,在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即可

[root@tiejiang ~]# service nginx restart

然后在Discuz! X2论坛后台-全局-SEO设置-URL静态化,选择你需要开启的页面,点击提交,即可实现静态化。


//下面这个css和插件后台设置的主题有关系,如果需要换样式,则需要修改以下CSS名称

从零到一,创造未来!跨零代码综合IT问题解决服务站,欢迎你的到来。运维教程 只为你绽放。

本文固定链接: http://kua0.com/2019/02/10/linux环境下discuz-x2论坛nginx伪静态规则设置-linux安全运维_跨零代/

为您推荐

发表评论

电子邮件地址不会被公开。 必填项已用*标注