一不小心就 發表於 2023-10-11 00:00:00

dedecms如何实现tag标签伪静态的方法

<p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, " microsoft="">
        dedecms的tag标签是一个很好管理关键词的功能,通过tag标签可以找到相关的关键词内容。但是dedecms的tag标签系统默认是/tags.php?/tag标签/如下图。不利于SEO优化。那么如何将TAGS静态化呢?(即改成.html)。</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, " microsoft="">
        这里主要是通过修改调用的标签进行伪静态。</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, " microsoft="" text-align:=""><img style="max-width:100%!important;height:auto!important;" title="dedecms如何实现tag标签伪静态的方法" alt="dedecms如何实现tag标签伪静态的方法" src="https://zhuji.jb51.net/uploads/img/202305/f51764ae92654f1f4cdc76d786e9d95e.jpg"/></p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, " microsoft="">
        1、在dedecms程序目录下找到tags.php。打开找到$PageNo=1到exit();的代码(如下图)。把这些代码替换成如下代码:</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, " microsoft="" text-align:=""><img style="max-width:100%!important;height:auto!important;" title="dedecms如何实现tag标签伪静态的方法" alt="dedecms如何实现tag标签伪静态的方法" src="https://zhuji.jb51.net/uploads/img/202305/7d790f8fb3a7f17c71e0aa7cc94a9cc5.jpg"/></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=""><pre class="brush:php;toolbar:false;">//tag伪静态
$tagid&nbsp;=&nbsp;(isset($tagid)&nbsp;&amp;&amp;&nbsp;is_numeric($tagid))&nbsp;?&nbsp;$tagid&nbsp;:&nbsp;0;
$PageNo&nbsp;=&nbsp;(isset($PageNo)&nbsp;&amp;&amp;&nbsp;is_numeric($PageNo))&nbsp;?&nbsp;$PageNo&nbsp;:&nbsp;1;
if&nbsp;($tagid&nbsp;==&quot;0&quot;)&nbsp;{
$dlist&nbsp;=&nbsp;new&nbsp;TagList($tag,&nbsp;&#39;tag.htm&#39;);
$dlist-&gt;Display();}
else{$row&nbsp;=&nbsp;$dsql-&gt;GetOne(&quot;SELECT&nbsp;tag&nbsp;FROM&nbsp;`tagindex`&nbsp;WHERE&nbsp;id&nbsp;={$tagid}&quot;);
if&nbsp;(!is_array($row))&nbsp;{ShowMsg(&#39;系统无此tag&#39;,&nbsp;&#39;-1&#39;);
exit();}
$tag&nbsp;=&nbsp;FilterSearch($row[&#39;tag&#39;]);
$dlist&nbsp;=&nbsp;new&nbsp;TagList($tag,&nbsp;&#39;taglist.htm&#39;);
$dlist-&gt;Display();}
exit();</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, " microsoft="">
        2、TAG调用标签。打开include/taglib/tag.lib.php文件找到$row[&#39;link&#39;] =$cfg_cmsurl.&quot;/tags.php?/&quot;.urlencode($row[&#39;keyword&#39;]).&quot;/&quot;;代码。将它替换成$row[&#39;link&#39;] = &quot;/tags/{$row[&#39;id&#39;]}.html&quot;;(注意符号都是英文,不是中文。不然查找不到,修改不成功)</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, " microsoft="">
        3、修改分页代码。同样打开include/arc.taglist.class.php,找到//获得上一页和下一页的链接。将//获得上一页和下一页的链接&nbsp; 至&nbsp; //获得数字链接之间的分页函数替换为如下函数:</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=""><pre class="brush:php;toolbar:false;">if($this-&gt;PageNo&nbsp;!=&nbsp;1)
{
$prepage.=&quot;上一页\r\n&quot;;
$indexpage=&quot;首页\r\n&quot;;
}
else
{
$indexpage=&quot;首页\r\n&quot;;
}
if($this-&gt;PageNo!=$totalpage&nbsp;&amp;&amp;&nbsp;$totalpage&gt;1)
{
$nextpage.=&quot;下一页\r
\n&quot;;
$endpage=&quot;末页\r\n&quot;;
}
else
{
$endpage=&quot;末页\r\n&quot;;&nbsp;&nbsp;}</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, " microsoft="">
        4、设置伪静态规则。新建一个txt文本,在文本里添加如下伪静态规则。然后另存为.htaccess上传到网站根目录即可(如果已有伪静态文件.htaccess,那么不要覆盖.htaccess。直接打开在里面添加如下规则保存即可。)</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=""><pre class="brush:php;toolbar:false;">RewriteEngine&nbsp;on
RewriteBase&nbsp;/
RewriteRule&nbsp;^tags/(+)_(+).html$&nbsp;tags.php?tagid=$1&amp;PageNo=$2&nbsp;
RewriteRule&nbsp;^tags/(+).html$&nbsp;tags.php?tagid=$1&nbsp;</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, " microsoft="">
        5、最后到dedecms后台更新一下,至此已完成所有的设置。可以看http://127.0.0.1/tags/1.html如下图的伪静态效果。</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, " microsoft="" text-align:=""><img style="max-width:100%!important;height:auto!important;" title="dedecms如何实现tag标签伪静态的方法" alt="dedecms如何实现tag标签伪静态的方法" src="https://zhuji.jb51.net/uploads/img/202305/d1c8571f5e43f95b1ad0f360831aa5e7.jpg"/></p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, " microsoft="">
        以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。</p>
頁: [1]
查看完整版本: dedecms如何实现tag标签伪静态的方法