返回列表 发帖
查看: 4922|回复: 5

discuz X3.4 TAG标签伪静态方法

15

主题

44

回帖

90

积分

渐入佳境

贡献
0 点
金币
28 个
发表于 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
回复

使用道具 举报

15

主题

44

回帖

90

积分

渐入佳境

贡献
0 点
金币
28 个
 楼主| 发表于 2019-7-15 10:55:14 | 显示全部楼层
怎么复制过来乱码呢!
回复 支持 反对

使用道具 举报

1

主题

4

回帖

7

积分

初学乍练

贡献
0 点
金币
2 个
QQ
发表于 2019-7-17 08:19:08 | 显示全部楼层
www.cpj123.com
www.xgllcp.cn
回复

使用道具 举报

1

主题

4

回帖

7

积分

初学乍练

贡献
0 点
金币
2 个
QQ
发表于 2019-7-17 08:19:34 | 显示全部楼层
www.cpj123.com
回复 支持 反对

使用道具 举报

19

主题

154

回帖

191

积分

渐入佳境

贡献
0 点
金币
10 个
QQ
发表于 2023-1-26 15:44:43 | 显示全部楼层
discuz!X3.4 TAG标签伪静态方法教程
https://www.jinhei.com/thread-426-1-1.html
已收藏,感谢分享。
技术维护,论坛,网站,小程序,app,商城定制开发QQ:515138
回复 支持 反对

使用道具 举报

TaC

80

主题

478

回帖

603

积分

自成一派

贡献
4 点
金币
11 个
发表于 2024-4-3 19:38:44 | 显示全部楼层
不错,3.5测试成功
回复 支持 反对

使用道具 举报

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

本版积分规则

  • 关注公众号
  • 有偿服务微信
  • 有偿服务QQ

手机版|小黑屋|Discuz! 官方交流社区 ( 皖ICP备16010102号 |皖公网安备34010302002376号 )|网站地图|star

GMT+8, 2024-4-20 16:26 , Processed in 0.038560 second(s), 7 queries , Redis On.

Powered by Discuz! W1.0 Licensed

Cpoyright © 2001-2024 Discuz! Team.

关灯 在本版发帖
有偿服务QQ
有偿服务微信
返回顶部
快速回复 返回顶部 返回列表