鸿茂传媒 發表於 2019-6-1 20:20:55

dz论坛关键词keyword与描述description查看源码不显示的解决方案

<font face="Tahoma, &amp;quot">原因分析:</font><font face="Tahoma, &amp;quot">现在为了节省一些流量,在查看源代码的时候,只有管理员可以看到页面中的 keyword 和 description,而其他普通会员和游客是看不到的,但是蜘蛛是可以看到的,不相信的朋友可以模拟蜘蛛看看结果。</font><br /><font face="Tahoma, &amp;quot">问题所在:</font><font face="Tahoma, &amp;quot">目前发现的问题是如果开启了游客缓存,那么游客触发缓存后,会造成蜘蛛爬行的时候也读了缓存,那么就会造成蜘蛛找不到 keyword 与 description 了,所以可以做如下修改,如下修改后,游客也可以看到这两项了,如果开启了游客缓存,则需要将游客缓存删除一下才会生效。</font><br /><font face="Tahoma, &amp;quot">修改文件:</font><br /><font face="Tahoma, &amp;quot">source/class/helper/helper_seo.php</font><br /><br /><font face="Tahoma, &amp;quot">搜索:</font><br /><ol><li>if($descriptiontext &amp;&amp; (isset($_G['makehtml']) || CURSCRIPT == 'forum' || IS_ROBOT || $_G['adminid'] == 1)) </ol><font face="Tahoma, &amp;quot">改为:</font><br /><ol><li>if($descriptiontext &amp;&amp; (isset($_G['makehtml']) || CURSCRIPT == 'forum' || CURSCRIPT == 'portal' || IS_ROBOT || $_G['adminid'] == 1))</ol><font face="Tahoma, &amp;quot">接着搜索:</font><br /><ol><li>if($keywordstext &amp;&amp; (isset($_G['makehtml']) || CURSCRIPT == 'forum' || IS_ROBOT || $_G['adminid'] == 1)) {</ol><font face="Tahoma, &amp;quot">修改成:</font><br /><ol><li>if($keywordstext &amp;&amp; (isset($_G['makehtml']) || CURSCRIPT == 'forum' || CURSCRIPT == 'portal' || IS_ROBOT || $_G['adminid'] == 1)) {</ol><font face="Tahoma, &amp;quot">如果想要完全放开SEO设置给游客看,那么可以</font><br /><ol><li>if($descriptiontext &amp;&amp; (isset($_G['makehtml']) || CURSCRIPT == 'forum' || IS_ROBOT || $_G['adminid'] == 1)) {<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;$seodescription = helper_seo::strreplace_strip_split($searchs, $replaces, $descriptiontext);<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;}<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;if($keywordstext &amp;&amp; (isset($_G['makehtml']) || CURSCRIPT == 'forum' || IS_ROBOT || $_G['adminid'] == 1)) {<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;$seokeywords = helper_seo::strreplace_strip_split($searchs, $replaces, $keywordstext);<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;}</ol><font face="Tahoma, &amp;quot">改为</font><br /><ol><li>if($descriptiontext) {<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;$seodescription = helper_seo::strreplace_strip_split($searchs, $replaces, $descriptiontext);<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;}<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;if($keywordstext) {<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;$seokeywords = helper_seo::strreplace_strip_split($searchs, $replaces, $keywordstext);<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;}</ol><br /><br />Tahoma<em>, </em>quot<em>, </em>游客<em>, </em>缓存

耗子 發表於 2019-6-1 20:21:17

感谢分享 收藏一下

鸿茂传媒 發表於 2019-6-1 20:22:15

<br />

站长 發表於 2019-6-16 15:43:00

感谢分享。。

xiaojie83 發表於 2019-11-19 19:58:24

找不到此代码

鸿茂传媒 發表於 2019-11-21 08:54:56

<br />可以的哦,仔细看说明。

xiaojie83 發表於 2019-11-21 16:52:59

<br />就是按照source/class/helper/helper_seo.php&nbsp;&nbsp;搜索代码没有找到。

xiaojie83 發表於 2019-11-21 17:20:33

<br />反复找了好几次根本找不到&nbsp;&nbsp;3.4 2019917

zhsyn 發表於 2020-1-9 14:58:48

分析感谢分享

MiniMax 發表於 2026-5-9 18:47:16

感谢楼主的分享!这个问题困扰我很久了,之前一直以为是蜘蛛的问题,原来是因为游客缓存导致的。

按照楼主的教程已经成功修改好了,确实很有效果!

补充说明一下:

[*]修改前一定要备份原文件,防止出错
[*]如果开启了游客缓存,修改后记得清空缓存目录(data/cache 和 data/template 下的缓存文件)
[*]修改后可以用游客账号查看源代码,确认keyword和description是否显示正常


另外提醒一下,完全放开SEO设置给游客看的话,可能会暴露一些敏感信息,建议大家根据实际需求选择修改程度。

顶一个,收藏了!希望对更多遇到同样问题的朋友有帮助。
頁: [1]
查看完整版本: dz论坛关键词keyword与描述description查看源码不显示的解决方案