不太想努力 發表於 2023-7-23 00:00:00

dede栏目列表首页与第一页链接出现重复的解决办法

<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        DEDECMS是SEO优化做得比较好的程序之一,但仍然有一些细节问题没处理好,今天要介绍的就是织梦dede栏目分页URL链接地址的SEO优化方法,在PHP7环境下测试通过</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        dede的栏目列表分页链接,仔细观察会发现,在栏目的首页会存在两个内容相同的2个不同url:</p>
<ul style='margin: 0px 0px 0px 25px; padding: 0.3em 0px; outline: none; list-style: decimal; line-height: 25px; word-break: break-word; font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>
<li>
                一个是在其他页面链接的栏目首页url是www.xxx.com/lanmu1/index.html</li>
        <li>
                另一个是栏目的分页给的链接URL是:www.xxx.com/lanmu1/list_1_1.html<br>
                 </li>
</ul>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        从SEO方面来说,是不太友好的,所以,本文就是针对这个问题,把两个URL统一成index.html</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        1,找到includerc.listview.class.php这个文件,将</p>
<div class="jb51code" style='margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";'>
        <pre class="brush:php;toolbar:false;">
$typedir= preg_replace('/{cmspath}/',$GLOBALS['cfg_cmspath'],$this-&gt;Fields['typedir']);</pre>
</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        这段代码添加到//获得上一页和主页的链接前面;</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        2,找到下面几行代码(就在//获得上一页和主页的链接下面)</p>
<div class="jb51code" style='margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";'>
        <pre class="brush:php;toolbar:false;">
if($this-&gt;PageNo != 1)
{
    $prepage.="&lt;li&gt;&lt;a href='".str_replace("{page}",$prepagenum,$tnamerule)."'&gt;上一页&lt;/a&gt;&lt;/li&gt;\r\n";
    $indexpage=”&lt;li&gt;&lt;a href='".str_replace("{page}",1,$tnamerule)."'&gt;首页&lt;/a&gt;&lt;/li&gt;\r\n";
}</pre>
</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        改成:</p>
<div class="jb51code" style='margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";'>
        <pre class="brush:php;toolbar:false;">
if($this-&gt;PageNo != 1)
{
    if($prepagenum==1)
    {
      $prepage.="&lt;li&gt;&lt;a href="".$typedir."/"&gt;上一页&lt;/a&gt;&lt;/li&gt;rn";
    }
    else {
      $prepage.="&lt;li&gt;&lt;a href="".str_replace("{page}",$prepagenum,$tnamerule).""&gt;上一页&lt;/a&gt;&lt;/li&gt;rn";
    }
    $indexpage="&lt;li&gt;&lt;a href="".$typedir."/"&gt;首页&lt;/a&gt;&lt;/li&gt;rn";
}
</pre>
</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        3.找到$listdd.="&lt;li&gt;&lt;a href='".str_replace("{page}",$j,$tnamerule)."'&gt;".$j."&lt;/a&gt;&lt;/li&gt;rn";</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        改成:</p>
<div class="jb51code" style='margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, "Microsoft YaHei";'>
        <pre class="brush:php;toolbar:false;">
if($j==1)
{
    $listdd.="&lt;li&gt;&lt;a href="".$typedir."/"&gt;".$j."&lt;/a&gt;&lt;/li&gt;rn";
}
else {
    $listdd.="&lt;li&gt;&lt;a href="".str_replace("{page}",$j,$tnamerule).""&gt;".$j."&lt;/a&gt;&lt;/li&gt;rn";
}
</pre>
</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        改完之后再去更新列表页试试看,首页、第一页 是不是都直接链接到栏目首页了。</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。</p>
頁: [1]
查看完整版本: dede栏目列表首页与第一页链接出现重复的解决办法