nginx下discuz3.2修改标签TAG伪静态教程

2025-04-08 08:18:25

1、确保已经在discuz后台开启了伪静态,这个不详解了,很简单。

2、把网站的伪静态文件下载到本地,路径一般在/usr/local/nginx/conf/xxx(你的伪静态文件名称).conf

3、使用文本编辑器将xxx.conf打开在rewrite ^([^\.]*)/([a-z]+[a-z0幻腾寂埒-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3 last; 上面添加如下两行rewrite ^([^\.]*)/tag.html$ $1/misc.php?mod=tag last;rewrite ^([^\.]*)/tag-([0-9]+)\.html$ $1/misc.php?mod=tag&id=$2 last;

nginx下discuz3.2修改标签TAG伪静态教程

4、保存之后上传,然后输入你的 你的域名/tag.html 试一下,如果可以,就进行下面的操作...

nginx下discuz3.2修改标签TAG伪静态教程

5、打开template/default/forum/viewthread_node_body.htm下载到本地打开查找:<a title="$var[1]" href="misc.php?mod=tag&id=$var[0]" target="_blank">$var[1]</a>替换为:<a title="$var[1]" href="tag-$var[0].html" target="_blank">$var[1]</a>

6、打开template/default/tag/tagitem.htm查找:<a href="misc.php?mod=tag">{lang tag}</a>替换为:<a href="tag.html">{lang tag}</a>查找:<a href="misc.php?mod=tag&id=$id">$tagname</a>替换为:<a href="tag-$id.html">$tagname</a>

7、到这里就已经修改完了,但是discuz默认禁止了百度爬行tag,如果不取消就没有意义修改tag的伪静态了,看下面继续

8、删除或注释掉根目录下misc.php的这段代码$discuz->reject_robot();

9、robots.txt文件删除一下两条禁止蜘蛛抓去的规则:Disallow: /misc.phpDisallow: /*?mod=misc*

10、修改完之后上传,后台刷新下缓存就可以了。

11、最后提供一下完整版的discuz3.2规则: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 ^([^\.]*)/tag.html$ $1/misc.php?mod=tag last;rewrite ^([^\.]*)/tag-([0-9]+)\.html$ $1/misc.php?mod=tag&id=$2 last;rewrite ^([^\.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3 last;rewrite ^/tag-(.+)\.html$ /tag.php?name=$1 last;if (!-e $request_filename) { return 404;}

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢