原因分析:由于discuz SEO机制,为了节省一些流量,在查看源代码的时候,只有蜘蛛和管理员可以看到页面中的 keyword 和 description,而其他普通会员和游客是看不到的,但是蜘蛛是可以看到的,不相信的朋友可以模拟蜘蛛看看结果。

问题所在:目前发现的问题是如果开启了游客缓存,那么游客触发缓存后,会造成蜘蛛爬行的时候也读了缓存,那么就会造成蜘蛛找不到 keyword 与 description 了,所以可以做如下修改,如下修改后,游客也可以看到这两项了,如果开启了游客缓存,则需要将游客缓存删除一下才会生效。

修改discuz SEO文件:source/class/helper/helper_seo.php

如果想要完全放开SEO设置给游客看,那么可以将:

if($descriptiontext && (isset($_G['makehtml']) || CURSCRIPT == 'forum' || IS_ROBOT || $_G['adminid'] == 1)) {
  $seodescription = helper_seo::strreplace_strip_split($searchs, $replaces, $descriptiontext);
}
if($keywordstext && (isset($_G['makehtml']) || CURSCRIPT == 'forum' || IS_ROBOT || $_G['adminid'] == 1)) {
  $seokeywords = helper_seo::strreplace_strip_split($searchs, $replaces, $keywordstext);
}

修改为:

if($descriptiontext) {
  $seodescription = helper_seo::strreplace_strip_split($searchs, $replaces, $descriptiontext);
}
if($keywordstext) {
  $seokeywords = helper_seo::strreplace_strip_split($searchs, $replaces, $keywordstext);
}

Discuz X3/X3.1/X3.4适用,修改后,在管理后台更新下数据缓存,刷新门户首页即可在游客模式下看到Keyword和Description

觉得上面的内容有用吗?快来点个赞吧!

点赞() 我要打赏

温馨提示 : 本站内容来自会员投稿以及互联网,所有源码及教程均为作者总结编辑,请大家在使用过程中提前做好备份,以免发生无法预知的错误,源码类教程请勿直接用于生产环境!

 可能感兴趣的文章