音乐吧 - www.52290.com

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1254|回复: 0

Discuz! TAG标签伪静态方案(1327.net)

[复制链接]

1056

主题

1090

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

音乐币
101
贡献
537
金钱
4385
威望
2120
相册
1

推广达人宣传达人突出贡献荣誉管理最佳新人活跃会员

QQ
发表于 2017-5-2 15:26:58 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?注册

x
Discuz X3.1默认是禁止搜索引擎访问 misc.php 文件的,因此 tag 不会被收录。
我们可以将 tag 网址伪静态化,这样不仅使 tag 网址看上去更规范美观,还使 tag 页面可以被百度收录。
第一步,复制根目录下的 misc.php 文件为 misc_tag.php 文件,删除其中的 $discuz->reject_robot(); (否则搜索引擎无法访问)。
第二步,增加伪静态规则(以Nginx为例)。
rewrite ^([^\.]*)/tag.html$ $1/misc_tag.php?mod=tag last;
rewrite ^([^\.]*)/tag-([1-9][0-9]*)-1\.html$ $1/misc_tag.php?mod=tag&id=$2 last;
rewrite ^([^\.]*)/tag-([1-9][0-9]*)-([2-9]|[1-9][0-9]+)\.html$ $1/misc_tag.php?mod=tag&id=$2&type=thread&page=$3 last;
注意:必须添加在“插件”页面的伪静态规则(即 rewrite ^([^\.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$23 last; 行)之前的任意位置。添加后需要 重载 或 关闭后再启动 Nginx后生效(仅直接重启无效)。
该规则使 tag标签页面 支持以网址 tag-标签编号-标签页数.html 访问指定标签页面。
第三步,修改Discuz程序,使 tag链接 由原有的动态链接换为伪静态链接。
1、打开 template/default/tag/tagitem.htm 模板文件,
将 <a class="xi2" href="misc.php?mod=tag&id=$id&type=thread">{lang more}...</a> 修改为:
<a href="tag-$id-2.html" class="xi2" style="font-weight: bold;">查看更多相关帖子 >>></a>
将 <a class="xi2" href="misc.php?mod=tag&id=$id&type=blog">{lang more}...</a> 修改为:
<a href="misc.php?mod=tag&id=$id&type=blog" class="xi2" style="font-weight: bold;">查看更多相关日志 >>></a>
将 <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-1.html">$tagname</a>
将 <!--{loop $threadlist $thread}--> 修改为 {eval $tiaoshu = 0}<!--{loop $threadlist $thread}-->{eval $tiaoshu ++;}
将第一个 <!--{if empty($showtype)}--> 修改为 <!--{if empty($showtype) && $tiaoshu >= 20}-->
将 action="misc.php?mod=tag" 修改为 action="tag.html"
2、修改翻页按钮。打开 source/module/misc/misc_tag.php 文件,
将 $multipage = multi($count, $tpp, $page, "misc.php?mod=tag&id=$tag[tagid]&type=thread"); 修改为
$multipage = multi_guide($count, $tpp, $page, "tag-$tag[tagid]");
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|小黑屋|手机版|Archiver|版权声明| 音乐吧 52290 ( 桂ICP备2021006182号 )

GMT+8, 2024-5-16 14:21 , Processed in 0.049699 second(s), 25 queries .

Powered by Discuz! X3.4

© 2001-2023 07726.Com Inc.

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