查看: 19|回复: 4

[教程] discuz X3.4 TAG标签伪静态方法

[复制链接]

3

主题

2

回帖

0

积分

积极分子

金币
2
阅读权限
220
精华
0
威望
0
贡献
0
在线时间
0 小时
注册时间
2011-10-4
发表于 2019-7-15 10:54:45 | 显示全部楼层 |阅读模式
要养成原文件备份的好习惯。演示地址:https://bbs.jatxh.cn/tag.html

1. 修改帖子内tag标签链接,使其伪静态。
打开template/default(模板风格)/forum/viewthread_node_body.htm,查找:
  • <a title="$var[1]" href="misc.php?mod=tag&id=$var[0]" target="_blank">$var[1]</a>

[color=rgb(51, 51, 51) !important]复制代码


替换为
  • <a title="$var[1]" href="tag-$var[0].html" target="_blank">$var[1]</a>

[color=rgb(51, 51, 51) !important]复制代码


2. 修改tag页,使各个标签链接伪静态。
打开template/default/tag/tag.htm,查找
  • <a href="misc.php?mod=tag&id=$tag[tagid]" title="$tag[tagname]" target="_blank" class="xi2">$tag[tagname]</a>

[color=rgb(51, 51, 51) !important]复制代码


替换为
  • <a href="tag-$tag[tagid].html" title="$tag[tagname]" target="_blank" class="xi2">$tag[tagname]</a>

[color=rgb(51, 51, 51) !important]复制代码


3. 修改tag列表页当前位置,使其路径链接伪静态。
打开template/default/tag/tagitem.htm,查找
  • <a href="misc.php?mod=tag">{lang tag}</a>

[color=rgb(51, 51, 51) !important]复制代码



替换为
  • <a href="tag.html">{lang tag}</a>

[color=rgb(51, 51, 51) !important]复制代码


再查找
  • <a href="misc.php?mod=tag&id=$id">$tagname</a>

[color=rgb(51, 51, 51) !important]复制代码


替换为
  • <a href="tag-$id.html">$tagname</a>

[color=rgb(51, 51, 51) !important]复制代码


4. 让搜索引擎蜘蛛可爬。
修改根目录下robort.txt,删除
  • Disallow: /misc.php
  • Disallow: /*?mod=misc*

[color=rgb(51, 51, 51) !important]复制代码


修改根目录下misc.php文件,注释或删除
  • $discuz->reject_robot();

[color=rgb(51, 51, 51) !important]复制代码


5. 添加伪静态规则。
linux系统(.htaccess或httpd.conf)伪静态规则:
  • RewriteCond %{QUERY_STRING} ^(.*)$
  • RewriteRule ^tag-(.+)\.html$ misc.php?mod=tag&id=$1
  • RewriteCond %{QUERY_STRING} ^(.*)
  • RewriteRule ^tag\.html$ misc.php?mod=tag

[color=rgb(51, 51, 51) !important]复制代码


WIN的添加(httpd.ini)伪静态规则:(未测,是否可用未知)
  • RewriteRule ^(.*)/tag-(.+)\.html*$ $1/misc.php\?mod=tag&id=$2
  • RewriteRule ^(.*)/tag\.html*$ $1/misc.php\?mod=tag

[color=rgb(51, 51, 51) !important]复制代码


要保证规则文件内最后一条伪静态规则为
  • RewriteRule ^([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ plugin.php?id=$1:$2&%1

[color=rgb(51, 51, 51) !important]复制代码


或者
  • RewriteRule ^(.*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html(\?(.*))*$ $1/plugin\.php\?id=$2:$3&$5

[color=rgb(51, 51, 51) !important]复制代码


否则显示插件不存在或已关闭。



原文地址:https://bbs.jatxh.cn/thread-73980-1-1.html
quot, rgb, list, size
回复

使用道具 举报

3

主题

2

回帖

0

积分

积极分子

金币
2
阅读权限
220
精华
0
威望
0
贡献
0
在线时间
0 小时
注册时间
2011-10-4
 楼主| 发表于 2019-7-15 10:55:14 | 显示全部楼层
怎么复制过来乱码呢!
回复

使用道具 举报

0

主题

1

回帖

0

积分

积极分子

金币
1
阅读权限
220
精华
0
威望
0
贡献
0
在线时间
0 小时
注册时间
2008-4-27
发表于 2019-7-17 08:19:34 | 显示全部楼层
www.cpj123.com
回复

使用道具 举报

8

主题

29

回帖

0

积分

积极分子

金币
29
阅读权限
220
精华
0
威望
0
贡献
0
在线时间
0 小时
注册时间
2010-10-29
发表于 2023-1-26 15:44:43 | 显示全部楼层
discuz!X3.4 TAG标签伪静态方法教程
https://www.jinhei.com/thread-426-1-1.html
已收藏,感谢分享。
回复

使用道具 举报

0

主题

67

回帖

0

积分

积极分子

金币
67
阅读权限
220
精华
0
威望
0
贡献
0
在线时间
0 小时
注册时间
2010-7-11
发表于 2024-4-3 19:38:44 | 显示全部楼层
不错,3.5测试成功
回复

使用道具 举报

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

本版积分规则

相关侵权、举报、投诉及建议等,请发 E-mail:qiongdian@foxmail.com

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部