Discuz论坛SEO优化修改 不指定

jed , 2006-9-3 07:49 , 搜索优化 , 评论(0) , 阅读(4003) , Via 本站原创 | |
*********************************************
纯属本人原创,原载于落伍论坛
*********************************************
众所周知,Discuz在SEO优化上做的并不是很好,很网友反应需要这方面的支持,我把自己做的一些简单的优化措施,贡献给大家,希望借此能够落伍。
为修改前,Discuz的标题栏显示的是:网站名--版块名--文章名,有点SEO方面知识的人都知道,这样不利于搜索爬虫搜索到,精明做法就是让它显示的时候,如下:文章名--版块名--网站名。(本人是在Discuz4.1.0版本上修改的)
具体修改如下:
forumdisplay.php
====================================

if($forum['type'] == 'forum') {
       $navigation = "» $forum[name]";
       $navtitle = ' - '.strip_tags($forum['name']);
} else {
       $forumup = $_DCACHE['forums'][$forum['fup']]['name'];
       $navigation = "» <a href=\"forumdisplay.php?fid=$forum[fup]\">$forumup</a> » $forum[name]";
       $navtitle = ' - '.strip_tags($forumup).' - '.strip_tags($forum['name']);
}


修改为:


if($forum['type'] == 'forum') {
       $navigation = "» $forum[name]";
       $navtitle = strip_tags($forum['name']);
} else {
       $forumup = $_DCACHE['forums'][$forum['fup']]['name'];
       $navigation = "» <a href=\"forumdisplay.php?fid=$forum[fup]\">$forumup</a> » $forum[name]";
       $navtitle = strip_tags($forumup).' - '.strip_tags($forum['name']);
}


============================================================



viewthread.php
================================================

$navtitle = ' - '.strip_tags($forum['name']).' - '.$thread['subject'];
if($forum['type'] == 'sub') {
       $query = $db->query("SELECT fid, name FROM {$tablepre}forums WHERE fid='$forum[fup]'");
       $fup = $db->fetch_array($query);
       $navigation = "» <a href=\"forumdisplay.php?fid=$fup[fid]\">$fup[name]</a> $navigation";
       $navtitle = ' - '.strip_tags($fup['name']).$navtitle;
}


修改为:


$navtitle = $thread['subject'].' -  '.strip_tags($forum['name']);
if($forum['type'] == 'sub') {
       $query = $db->query("SELECT fid, name FROM {$tablepre}forums WHERE fid='$forum[fup]'");
       $fup = $db->fetch_array($query);
       $navigation = "» <a href=\"forumdisplay.php?fid=$fup[fid]\">$fup[name]</a> $navigation";
       $navtitle = $navtitle;
}



post.php
====================================================

if(!empty($tid) && !empty($fid)) {
       $query = $db->query("SELECT * FROM {$tablepre}threads WHERE tid='$tid' AND displayorder>='0'");
       $thread = $db->fetch_array($query);
       $fid = $thread['fid'];
       $navigation = "» <a href=\"viewthread.php?tid=$tid\">$thread[subject]</a>";
       $navtitle = " - $thread[subject]";

       if($thread['readperm'] && $thread['readperm'] > $readaccess && !$forum['ismoderator'] && $thread['authorid'] != $discuz_uid) {
               showmessage('thread_nopermission', NULL, 'NOPERM');
       }
}

$navigation = "» <a href=\"forumdisplay.php?fid=$fid".($extra ? '&'.preg_replace("/^(&)*/", '', $extra) : '')."\">$forum[name]</a> $navigation";
$navtitle = ' - '.strip_tags($forum['name']).$navtitle;
if($forum['type'] == 'sub') {
       $query = $db->query("SELECT name, fid FROM {$tablepre}forums WHERE fid='$forum[fup]'");
       $fup = $db->fetch_array($query);
       $navigation = "» <a href=\"forumdisplay.php?fid=$fup[fid]\">$fup[name]</a> $navigation";
       $navtitle = ' - '.strip_tags($fup['name']).$navtitle;
}



修改为:


if(!empty($tid) && !empty($fid)) {
       $query = $db->query("SELECT * FROM {$tablepre}threads WHERE tid='$tid' AND displayorder>='0'");
       $thread = $db->fetch_array($query);
       $fid = $thread['fid'];
       $navigation = "» <a href=\"viewthread.php?tid=$tid\">$thread[subject]</a>";
       $navtitle = $thread[subject];

       if($thread['readperm'] && $thread['readperm'] > $readaccess && !$forum['ismoderator'] && $thread['authorid'] != $discuz_uid) {
               showmessage('thread_nopermission', NULL, 'NOPERM');
       }
}

$navigation = "» <a href=\"forumdisplay.php?fid=$fid".($extra ? '&'.preg_replace("/^(&)*/", '', $extra) : '')."\">$forum[name]</a> $navigation";
$navtitle = strip_tags($forum['name']).$navtitle;
if($forum['type'] == 'sub') {
       $query = $db->query("SELECT name, fid FROM {$tablepre}forums WHERE fid='$forum[fup]'");
       $fup = $db->fetch_array($query);
       $navigation = "» <a href=\"forumdisplay.php?fid=$fup[fid]\">$fup[name]</a> $navigation";
       $navtitle = $navtitle;
}






./temlpates/default/header.htm
=======================================================

<title>$bbname $seotitle $navtitle - powered by Discuz!</title>
修改为:


<title><!--{if $navtitle}-->$navtitle - $bbname<!--{else}-->$bbname<!--{/if}--> </title>

=============================================================

如果大家觉得自己修改麻烦的话,可以直接下载我修改过的这几个文件,不过里面不包含header.htm的修改,因为大家用的模板不同,只须将所用模板修改即可。
下载地址:
http://www.dzhope.com/dzhope.rar
演示网站:http://bbs.dzhope.com
Tags: ,
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]