杉宫竹苑工作室

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 3858|回复: 0

[Discuz] Discuz x3.2 全局伪静态SEO优化

[复制链接]
发表于 2014-11-21 15:31:03 | 显示全部楼层 |阅读模式

正式会员享受无限制浏览网站功能和高速网盘下载,赶快加入本站吧!

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

x

forum_redirect.php的修改很重要,不知道为什么网上的discuz论坛的管理员都这么懒,这个帖子改一下,全站伪静态很容易就实现了。
一、>discuz x2论坛首页“最后发表”帖子链接静态化

现在还没有找到完美的解决方法,不过通过这样做还是基本实现我想要的形式,有两种方法,各有各的不足。

方法1、/source/module/forum/ 下的forum_redirect.php把
  1. dheader(‘Location: forum.php?mod=viewthread&tid=’.$_G['tid'].$pageadd.’#lastpost’);
复制代码
换成
  1. header("HTTP/1.1 301 Moved Permanently");
  2. dheader(‘Location:thread-’.$_G['tid'].’-’.$page.’-1.html#lastpost’);
复制代码
虽然首页显示是动态地址,但是点击就会301跳转到静态页,这个方法是定死的,取消了伪静态设置还是会跳转到这个伪静态地址,所以一定开启了伪静态而且必须是系统默认的方式,才可以这样修改

方法2、这个方法是直接修改模板discuz.htm中的
  1. forum.php?mod=redirect&tid=$forum[lastpost][tid]&goto=lastpost#lastpost
复制代码
换成
  1. forum.php?mod=viewthread&tid=$forum[lastpost][tid]
复制代码
一共有三处
这个方法可是完美支持自动判断网站是伪静态还是动态,不足之处是点击不会跳转到最后回复的帖子,只会跳转到最后回复的主题。

二、discuz x2“上一主题、下一主题”链接静态化

利用$_G[tid]-1 和 $_G[tid]+1 来做连接
打开viewthread.htm文件
查找
  1. <a href="forum.php?mod=redirect&goto=nextoldset&tid=$_G[tid]" title="{lang last_thread}"><img src="{IMGDIR}/thread-prev.png" alt="{lang last_thread}" class="vm" /></a>
  2. <a href="forum.php?mod=redirect&goto=nextnewset&tid=$_G[tid]" title="{lang next_thread}"><img src="{IMGDIR}/thread-next.png" alt="{lang next_thread}" class="vm" /></a>
复制代码
修改为:
  1. <!–{eval $up_thread=$_G[tid]-1;$down_thread=$_G[tid]+1;}–>
  2. <a href="thread-$up_thread-1-1.html" rel="nofollow" title="{lang last_thread}"><img src="{IMGDIR}/thread-prev.png" alt="{lang last_thread}" class="vm" /></a>
  3. <a href="thread-$down_thread-1-1.html" rel="nofollow" title="{lang next_thread}"><img src="{IMGDIR}/thread-next.png" alt="{lang next_thread}" class="vm" /></a>
复制代码
如果主题被删除就找不到了用这种方法。。。

三、Discuz X2.0论坛帖“复制链接”伪静态实现方法

打开 /template/default/forum/viewthread.htm 在大约200行左右找到以下代码:
  1. forum.php?mod=viewthread&tid=$_G[tid]$fromuid
复制代码
换成
  1. forum.php?mod=viewthread&tid=$_G[tid]
复制代码
就可以了

四、discuz x2帖子列表页默认打开修改为新窗口打开

discuz x2帖子列表默认打开是本窗口打开的,不符合国内用户使用习惯,最正规的修改如下面两个步骤:
1: 根目录/static/js/forum.js
找到 atarget函数
改成
  1. function atarget(obj) {
  2. obj.target = getcookie(‘atarget’) ?  ”: ‘_blank’;
  3. }
复制代码
2:把‘打开新窗口’改成‘本窗口打开’ 修改如下:
根目录/template/default/forum/forumdisplay_list.html文件中:
找到
  1. <span id="atarget" {if !empty($_G['cookie']['atarget'])}onclick="setatarget(0)" class="y atarget_1"{else}onclick="setatarget(1)" class="y"{/if} title="{lang new_window_thread}">{lang new_window}</span>
复制代码
用下边的替换即可
  1. <span id="atarget" {if !empty($_G['cookie']['atarget'])}onclick="setatarget(0)" class="y atarget_1"{else}onclick="setatarget(1)" class="y"{/if} title="本窗口打开帖子">本窗口</span>
复制代码
五、discuz x2 rss输出链接的静态化
如何将rss输出结果变成静态化呢,下面是具体修改步骤:

打开source/module/forum/forum_rss.php

1、论坛首页URL标准化:如果不需要标准的人不用修改
  1. <link>{$_G[siteurl]}forum.php</link>
复制代码
改为
  1. <link>{$_G[siteurl]}</link>
复制代码
2、主题列表页URL伪静态:把
  1. <link>{$_G[siteurl]}forum.php?mod=forumdisplay&fid=$rssfid</link>
复制代码
改为
  1. <link>$_G[siteurl]forum-$forum[fid]-1.html</link>
复制代码
3、帖子内容页URL伪静态:把
  1. <link>$_G[siteurl]forum.php?mod=viewthread&tid=$thread[tid]</link>
复制代码
改为
  1. <link>$_G[siteurl]thread-$thread[tid]-1-1.html</link>
复制代码
六、discuz x2 帖子链接统一(帖子链接唯一化)

开启了伪静态的帖子链接是这样的形式:thread-x-y-z.html,其中x是帖子的id(固定不变的),y是帖子的页数(也是固定的),z是帖子所在列表页的页数(这个是变化的,随着帖子回复或者新帖的加入,所处位置就会变化),如何让z不变呢,可能通过修改template/default/forum/forumdisplay_list.htm解决,修改后虽然帖子的url统一了,但是在帖子页里点击“返回列表”,返回的是列表第一页而不是帖子所在的列表页。

找到
  1. <a href="forum.php?mod=viewthread&tid=$thread[tid]&{if $_G['gp_archiveid']}archiveid={$_G['gp_archiveid']}&{/if}extra=$extra"$thread[highlight]{if $thread['isgroup'] == 1 || $thread['forumstick']} target="_blank"{else} onclick="atarget(this)"{/if} class="xst" >$thread[subject]</a>
复制代码
修改为
  1. <a href="forum.php?mod=viewthread&tid=$thread[tid]" $thread[highlight]{if $thread['isgroup'] == 1} target="_blank"{/if} onclick="atarget(this)" class="xst">$thread[subject]</a>
复制代码
7.开启伪静态。
全局,seo设置,
论坛主题列表页 {fid}, {page}   
论坛主题内容页 {tid}, {page}, {prevpage}
可用上打勾。
然后 点 查看当前的 Rewrite 规则
URL 静态化
回复

使用道具 举报

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

本版积分规则

QQ|小黑屋|手机版|Archiver|SgzyStudio

GMT+8, 2024-5-6 06:42 , Processed in 0.126086 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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