DedeCMS系统TAG标签伪静态设置方法 -电脑资料

电脑资料 时间:2019-01-01 我要投稿
【www.unjs.com - 电脑资料】

  DedeCMS的系统TAGS确实是一个非常好的功能,通过关键词链接可以快速寻找到相关内容,不过很多人希望能够将TAGS静态化这样更加利于SEO,CIT.CN也是对此进行了优化和调整,只不过cit小虫觉得这种更新内容比较频繁的列表最好采用伪静态的方式,这里就分享下技巧,

DedeCMS系统TAG标签伪静态设置方法

  1.修改前台显示链接

  我们这里达到的效果就是使原来/tags.php?keywors更改为/tags/keywords.html。

  这里主要修改下调用的标签,在/include/taglib/tag.lib.php中,在87行找到

<span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$row</span><span class="sh_symbol">[</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'link'</span><span class="sh_symbol">]</span> <span class="sh_symbol">=</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$cfg_cmsurl</span><span class="sh_symbol">.</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"/tags?"</span><span class="sh_symbol">.</span><span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">urlencode</span><span class="sh_symbol">(</span><span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$row</span><span class="sh_symbol">[</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'keyword'</span><span class="sh_symbol">]);</span>

  将其改为:

<span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$row</span><span class="sh_symbol">[</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'link'</span><span class="sh_symbol">]</span> <span class="sh_symbol">=</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$cfg_cmsurl</span><span class="sh_symbol">.</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"/tags/"</span><span class="sh_symbol">.</span><span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">urlencode</span><span class="sh_symbol">(</span><span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$row</span><span class="sh_symbol">[</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'keyword'</span><span class="sh_symbol">]).</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">".html"</span><span class="sh_symbol">;</span>

  2.修改分页代码

  我们需要修改include/arc.taglist.class.php,将分页函数替换为:

<span style="color: rgb(255, 0, 0); font-weight: normal; font-style. normal; " class="sh_comment">/**     *  获取动态的分页列表</span>
<span style="color: rgb(255, 0, 0); font-weight: normal; font-style. normal; " class="sh_comment">     *</span>
<span style="color: rgb(255, 0, 0); font-weight: normal; font-style. normal; " class="sh_comment">     * </span><span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">@access</span><span style="color: rgb(255, 0, 0); font-weight: normal; font-style. normal; " class="sh_comment">    public</span>
<span style="color: rgb(255, 0, 0); font-weight: normal; font-style. normal; " class="sh_comment">     * </span><span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">@param</span><span style="color: rgb(255, 0, 0); font-weight: normal; font-style. normal; " class="sh_comment">     int  $list_len  列表宽度</span>
<span style="color: rgb(255, 0, 0); font-weight: normal; font-style. normal; " class="sh_comment">     * </span><span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">@param</span><span style="color: rgb(255, 0, 0); font-weight: normal; font-style. normal; " class="sh_comment">     string  $listitem  列表样式</span>
<span style="color: rgb(255, 0, 0); font-weight: normal; font-style. normal; " class="sh_comment">     * </span><span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">@return</span><span style="color: rgb(255, 0, 0); font-weight: normal; font-style. normal; " class="sh_comment">    string</span>
<span style="color: rgb(255, 0, 0); font-weight: normal; font-style. normal; " class="sh_comment">     */</span>
    <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">function</span> <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">GetPageListDM</span><span class="sh_symbol">(</span><span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$list_len</span><span class="sh_symbol">,</span><span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$listitem</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"info,index,end,pre,next,pageno"</span><span class="sh_symbol">)</span>
    <span class="sh_cbracket">{</span>
        <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$prepage</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">""</span><span class="sh_symbol">;</span>
        <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$nextpage</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">""</span><span class="sh_symbol">;</span>
        <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$prepagenum</span> <span class="sh_symbol">=</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$this</span><span class="sh_symbol">-></span>PageNo <span class="sh_symbol">-</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_number">1</span><span class="sh_symbol">;</span>
        <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$nextpagenum</span> <span class="sh_symbol">=</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$this</span><span class="sh_symbol">-></span>PageNo <span class="sh_symbol">+</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_number">1</span><span class="sh_symbol">;</span>
        <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">if</span><span class="sh_symbol">(</span><span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$list_len</span> <span class="sh_symbol">==</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">""</span> <span class="sh_symbol">||</span> <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">preg_match</span><span class="sh_symbol">(</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"/[^0-9]/"</span><span class="sh_symbol">,</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$list_len</span><span class="sh_symbol">))</span>
        <span class="sh_cbracket">{</span>
            <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$list_len</span> <span class="sh_symbol">=</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_number">3</span><span class="sh_symbol">;</span>
        <span class="sh_cbracket">}</span>
        <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$totalpage</span> <span class="sh_symbol">=</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$this</span><span class="sh_symbol">-></span>TotalPage<span class="sh_symbol">;</span>
        <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">if</span><span class="sh_symbol">(</span><span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$totalpage</span> <span class="sh_symbol"><=</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_number">1</span> <span class="sh_symbol">&&</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$this</span><span class="sh_symbol">-></span>TotalResult <span class="sh_symbol">></span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_number">0</span><span class="sh_symbol">)</span>
        <span class="sh_cbracket">{</span>
            <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">return</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"<span class="</span>pageinfo<span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">">共1页/"</span><span class="sh_symbol">.</span><span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$this</span><span class="sh_symbol">-></span>TotalResult<span class="sh_symbol">.</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"条</span>"</span><span class="sh_symbol">;</span>
        <span class="sh_cbracket">}</span>
        <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">if</span><span class="sh_symbol">(</span><span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$this</span><span class="sh_symbol">-></span>TotalResult <span class="sh_symbol">==</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_number">0</span><span class="sh_symbol">)</span>
        <span class="sh_cbracket">{</span>
            <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">return</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"<span class="</span>pageinfo<span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">">共0页/"</span><span class="sh_symbol">.</span><span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$this</span><span class="sh_symbol">-></span>TotalResult<span class="sh_symbol">.</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"条</span>"</span><span class="sh_symbol">;</span>
        <span class="sh_cbracket">}</span>
        <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$maininfo</span> <span class="sh_symbol">=</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"<span class="</span>pageinfo<span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">">共{$totalpage}页/"</span><span class="sh_symbol">.</span><span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$this</span><span class="sh_symbol">-></span>TotalResult<span class="sh_symbol">.</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"条</span>rn"</span><span class="sh_symbol">;</span>
        <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$purl</span> <span class="sh_symbol">=</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$this</span><span class="sh_symbol">-></span><span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">GetCurUrl</span><span class="sh_symbol">();</span>
        <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$basename</span> <span class="sh_symbol">=</span> <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">basename</span><span class="sh_symbol">(</span><span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$purl</span><span class="sh_symbol">);</span>
        <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$tmpname</span> <span class="sh_symbol">=</span> <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">explode</span><span class="sh_symbol">(</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'.'</span><span class="sh_symbol">,</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$basename</span><span class="sh_symbol">);</span>
        
        <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$purl</span> <span class="sh_symbol">=</span> <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">str_replace</span><span class="sh_symbol">(</span><span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$basename</span><span class="sh_symbol">,</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">''</span><span class="sh_symbol">,</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$purl</span><span class="sh_symbol">).</span><span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">urlencode</span><span class="sh_symbol">(</span><span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$this</span><span class="sh_symbol">-></span>Tag<span class="sh_symbol">);</span>
        <span style="color: rgb(255, 0, 0); font-weight: normal; font-style. normal; " class="sh_comment">//var_dump($purl);exit;</span>
        <span style="color: rgb(255, 0, 0); font-weight: normal; font-style. normal; " class="sh_comment">//$purl .= "?/".urlencode($this->Tag);</span>
 
        <span style="color: rgb(255, 0, 0); font-weight: normal; font-style. normal; " class="sh_comment">//获得上一页和下一页的链接</span>
        <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">if</span><span class="sh_symbol">(</span><span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$this</span><span class="sh_symbol">-></span>PageNo <span class="sh_symbol">!=</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_number">1</span><span class="sh_symbol">)</span>
        <span class="sh_cbracket">{</span>
            <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$prepage</span><span class="sh_symbol">.=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"<li><a href='"</span><span class="sh_symbol">.</span><span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$purl</span><span class="sh_symbol">.</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"-$prepagenum'.html>上一页</a></li>rn"</span><span class="sh_symbol">;</span>
            <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$indexpage</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"<li><a href='"</span><span class="sh_symbol">.</span><span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$purl</span><span class="sh_symbol">.</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"-1.html'>首页</a></li>rn"</span><span class="sh_symbol">;</span>
        <span class="sh_cbracket">}</span>
        <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">else</span>
        <span class="sh_cbracket">{</span>
            <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$indexpage</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"<li><a>首页</a></li>rn"</span><span class="sh_symbol">;</span>
        <span class="sh_cbracket">}</span>
        <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">if</span><span class="sh_symbol">(</span><span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$this</span><span class="sh_symbol">-></span>PageNo<span class="sh_symbol">!=</span><span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$totalpage</span> <span class="sh_symbol">&&</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$totalpage</span><span class="sh_symbol">></span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_number">1</span><span class="sh_symbol">)</span>
        <span class="sh_cbracket">{</span>
            <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$nextpage</span><span class="sh_symbol">.=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"<li><a href='"</span><span class="sh_symbol">.</span><span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$purl</span><span class="sh_symbol">.</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"-$nextpagenum.html'>下一页</a></li>rn"</span><span class="sh_symbol">;</span>
            <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$endpage</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"<li><a href='"</span><span class="sh_symbol">.</span><span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$purl</span><span class="sh_symbol">.</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"-$totalpage.html'>末页</a></li>rn"</span><span class="sh_symbol">;</span>
        <span class="sh_cbracket">}</span>
        <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">else</span>
        <span class="sh_cbracket">{</span>
            <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$endpage</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"<li><a>末页</a></li>rn"</span><span class="sh_symbol">;</span>
        <span class="sh_cbracket">}</span>
 
        <span style="color: rgb(255, 0, 0); font-weight: normal; font-style. normal; " class="sh_comment">//获得数字链接</span>
        <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$listdd</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">""</span><span class="sh_symbol">;</span>
        <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$total_list</span> <span class="sh_symbol">=</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$list_len</span> <span class="sh_symbol">*</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_number">2</span> <span class="sh_symbol">+</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_number">1</span><span class="sh_symbol">;</span>
        <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">if</span><span class="sh_symbol">(</span><span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$this</span><span class="sh_symbol">-></span>PageNo <span class="sh_symbol">>=</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$total_list</span><span class="sh_symbol">)</span>
        <span class="sh_cbracket">{</span>
            <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$j</span> <span class="sh_symbol">=</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$this</span><span class="sh_symbol">-></span>PageNo <span class="sh_symbol">-</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$list_len</span><span class="sh_symbol">;</span>
            <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$total_list</span> <span class="sh_symbol">=</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$this</span><span class="sh_symbol">-></span>PageNo <span class="sh_symbol">+</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$list_len</span><span class="sh_symbol">;</span>
            <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">if</span><span class="sh_symbol">(</span><span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$total_list</span> <span class="sh_symbol">></span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$totalpage</span><span class="sh_symbol">)</span>
            <span class="sh_cbracket">{</span>
                <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$total_list</span> <span class="sh_symbol">=</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$totalpage</span><span class="sh_symbol">;</span>
            <span class="sh_cbracket">}</span>
        <span class="sh_cbracket">}</span>
        <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">else</span>
        <span class="sh_cbracket">{</span>
            <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$j</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_number">1</span><span class="sh_symbol">;</span>
            <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">if</span><span class="sh_symbol">(</span><span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$total_list</span> <span class="sh_symbol">></span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$totalpage</span><span class="sh_symbol">)</span>
            <span class="sh_cbracket">{</span>
                <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$total_list</span> <span class="sh_symbol">=</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$totalpage</span><span class="sh_symbol">;</span>
            <span class="sh_cbracket">}</span>
        <span class="sh_cbracket">}</span>
        <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">for</span><span class="sh_symbol">(</span><span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$j</span><span class="sh_symbol">;</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$j</span><span class="sh_symbol"><=</span><span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$total_list</span><span class="sh_symbol">;</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$j</span><span class="sh_symbol">++)</span>
        <span class="sh_cbracket">{</span>
            <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">if</span><span class="sh_symbol">(</span><span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$j</span> <span class="sh_symbol">==</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$this</span><span class="sh_symbol">-></span>PageNo<span class="sh_symbol">)</span>
            <span class="sh_cbracket">{</span>
                <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$listdd</span><span class="sh_symbol">.=</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"<li class="</span>thisclass<span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"><a>$j</a></li>rn"</span><span class="sh_symbol">;</span>
            <span class="sh_cbracket">}</span>
            <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">else</span>
            <span class="sh_cbracket">{</span>
                <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$listdd</span><span class="sh_symbol">.=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"<li><a href='"</span><span class="sh_symbol">.</span><span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$purl</span><span class="sh_symbol">.</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"-$j.html'>"</span><span class="sh_symbol">.</span><span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$j</span><span class="sh_symbol">.</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"</a></li>rn"</span><span class="sh_symbol">;</span>
            <span class="sh_cbracket">}</span>
        <span class="sh_cbracket">}</span>
        <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$plist</span>  <span class="sh_symbol">=</span>  <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">''</span><span class="sh_symbol">;</span>
        <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">if</span><span class="sh_symbol">(</span><span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">preg_match</span><span class="sh_symbol">(</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'/info/i'</span><span class="sh_symbol">,</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$listitem</span><span class="sh_symbol">))</span>
        <span class="sh_cbracket">{</span>
            <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$plist</span> <span class="sh_symbol">.=</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$maininfo</span><span class="sh_symbol">.</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">' '</span><span class="sh_symbol">;</span>
        <span class="sh_cbracket">}</span>
        <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">if</span><span class="sh_symbol">(</span><span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">preg_match</span><span class="sh_symbol">(</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'/index/i'</span><span class="sh_symbol">,</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$listitem</span><span class="sh_symbol">))</span>
        <span class="sh_cbracket">{</span>
            <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$plist</span> <span class="sh_symbol">.=</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$indexpage</span><span class="sh_symbol">.</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">' '</span><span class="sh_symbol">;</span>
        <span class="sh_cbracket">}</span>
        <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">if</span><span class="sh_symbol">(</span><span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">preg_match</span><span class="sh_symbol">(</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'/pre/i'</span><span class="sh_symbol">,</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$listitem</span><span class="sh_symbol">))</span>
        <span class="sh_cbracket">{</span>
            <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$plist</span> <span class="sh_symbol">.=</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$prepage</span><span class="sh_symbol">.</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">' '</span><span class="sh_symbol">;</span>
        <span class="sh_cbracket">}</span>
        <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">if</span><span class="sh_symbol">(</span><span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">preg_match</span><span class="sh_symbol">(</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'/pageno/i'</span><span class="sh_symbol">,</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$listitem</span><span class="sh_symbol">))</span>
        <span class="sh_cbracket">{</span>
            <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$plist</span> <span class="sh_symbol">.=</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$listdd</span><span class="sh_symbol">.</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">' '</span><span class="sh_symbol">;</span>
        <span class="sh_cbracket">}</span>
        <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">if</span><span class="sh_symbol">(</span><span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">preg_match</span><span class="sh_symbol">(</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'/next/i'</span><span class="sh_symbol">,</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$listitem</span><span class="sh_symbol">))</span>
        <span class="sh_cbracket">{</span>
            <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$plist</span> <span class="sh_symbol">.=</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$nextpage</span><span class="sh_symbol">.</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">' '</span><span class="sh_symbol">;</span>
        <span class="sh_cbracket">}</span>
        <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">if</span><span class="sh_symbol">(</span><span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">preg_match</span><span class="sh_symbol">(</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'/end/i'</span><span class="sh_symbol">,</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$listitem</span><span class="sh_symbol">))</span>
        <span class="sh_cbracket">{</span>
            <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$plist</span> <span class="sh_symbol">.=</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$endpage</span><span class="sh_symbol">.</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">' '</span><span class="sh_symbol">;</span>
        <span class="sh_cbracket">}</span>
        <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">return</span> <span style="color: rgb(34, 95, 45); font-weight: normal; font-style. normal; " class="sh_variable">$plist</span><span class="sh_symbol">;</span>
    <span class="sh_cbracket">}</span>

  3.设置伪静态规则

  我们这里以iis7为例子,设置以下规则:

 <span style="color: rgb(160, 32, 240); font-weight: normal; font-style. normal; " class="sh_preproc"><?xml</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">version</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"1.0"</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">encoding</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"UTF-8"</span><span style="color: rgb(160, 32, 240); font-weight: normal; font-style. normal; " class="sh_preproc">?></span>

<span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword"><configuration></span>

    <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword"><system.webServer></span>

        <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword"><rewrite></span>

            <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword"><rules></span>

                <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword"><rule</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">name</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"weather1"</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">stopProcessing</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"true"</span><span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">></span>

                    <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword"><match</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">url</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"tags/([^-]+).html$"</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">ignoreCase</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"true"</span> <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">/></span>

                    <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword"><conditions</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">logicalGrouping</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"MatchAll"</span><span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">></span>

                        <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword"><add</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">input</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"{REQUEST_FILENAME}"</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">matchType</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"IsFile"</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">negate</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"true"</span> <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">/></span>

                        <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword"><add</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">input</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"{REQUEST_FILENAME}"</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">matchType</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"IsDirectory"</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">negate</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"true"</span> <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">/></span>

                    <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword"></conditions></span>

                    <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword"><action</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">type</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"Rewrite"</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">url</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"/tags.php?/{R:1}"</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">appendQueryString</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"false"</span> <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">/></span>

                <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword"></rule></span>

                <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword"><rule</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">name</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"weather2"</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">stopProcessing</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"true"</span><span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">></span>

                    <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword"><match</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">url</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"tags/([^-]+)-([0-9]+).html$"</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">ignoreCase</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"true"</span> <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">/></span>

                    <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword"><conditions</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">logicalGrouping</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"MatchAll"</span><span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">></span>

                        <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword"><add</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">input</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"{REQUEST_FILENAME}"</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">matchType</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"IsFile"</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">negate</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"true"</span> <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">/></span>

                        <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword"><add</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">input</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"{REQUEST_FILENAME}"</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">matchType</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"IsDirectory"</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">negate</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"true"</span> <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">/></span>

                    <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword"></conditions></span>

                    <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword"><action</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">type</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"Rewrite"</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">url</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"/tags.php?/{R:1}/{R:2}"</span> <span style="color: rgb(0, 0, 255); font-weight: normal; font-style. normal; " class="sh_type">appendQueryString</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"false"</span> <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">/></span>

                <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword"></rule></span>

            <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword"></rules></span>

        <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword"></rewrite></span>

    <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword"></system.webServer></span>

<span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword"></configuration></span>

  可以直接保存为web.config放在站点根目录,

电脑资料

DedeCMS系统TAG标签伪静态设置方法》(https://www.unjs.com)。

  4.重新生成html页面

  这个操作就不用说了,全部重新生成下,至此全部修改完毕。

  5.预览查看显示结果

  至此,我们已经完成了所有的设置,可以查看:预览效果。

最新文章