無論你網站全站是靜態或者動態還是偽靜態,此教程都可以設置TAG標簽頁為偽靜態,并且是單鏈接id的形式
按此教程操作后,電腦站TAG標簽url會像如下:
- TAG標簽首頁 http://m.gjgbw.com/tags.html
- TAG標簽列表 http://m.gjgbw.com/tags/9.html
- TAG標簽分頁 http://m.gjgbw.com/tags/9_2.html
按此教程操作后,手機站TAG標簽url會像如下:
- TAG標簽首頁 http://m.91084.com/tags.html
- TAG標簽列表 http://m.91084.com/tags/9.html
- TAG標簽分頁 http://m.91084.com/tags/9_2.html
電腦站TAG偽靜態實現教程
1、/tags.php 找到 18行
if(isset($tags[2])) $PageNo = intval($tags[2]);
在它下面加入
$tagid = intval($tag);if(!empty($tagid)){$row = $dsql->GetOne("SELECT tag FROM `dede_tagindex` WHERE id = {$tagid}");if(!is_array($row)){ShowMsg("系統無此標簽,可能已經移除!","-1");exit();}else{$tag = $row['tag'];define('DEDERETAG', 'Y');}}else{$tag = '';}
如圖

2、/include/taglib/tag.lib.php 找到 87行
$row['link'] = $cfg_cmsurl."/tags.php?/".urlencode($row['keyword'])."/";
改成
$row['link'] = $cfg_cmsurl."/tags/".$row['id'].".html";
3、/include/arc.taglist.class.php 找到 458行
$purl .= "?/".urlencode($this->Tag);
改成
if(!defined('DEDERETAG')){$purl .= "?/".urlencode($this->Tag);}
繼續找到
return $plist;
在它上面加入
if(defined('DEDERETAG')){$plist = preg_replace('/_(\d+).html/i','.html',$plist);$plist = preg_replace('/.html\/(\d+)\//i','_\\1.html',$plist);}
4、電腦站TAG標簽偽靜態規則,根據自己網站的主機環境選擇下面的規則
.htaccess (Apache)
RewriteEngine OnRewriteBase /RewriteRule ^tags\.html$ tags\.phpRewriteRule ^tags/([0-9]+)\.html$ tags\.php\?\/$1 [L]RewriteRule ^tags/([0-9]+)\.html$ tags\.php\?\/$1\/RewriteRule ^tags/([0-9]+)_([0-9]+)\.html$ tags\.php\?\/$1\/$2RewriteRule ^tags/([0-9]+)_([0-9]+)\.html$ tags\.php\?\/$1\/$2\/
Nginx
rewrite ^/tags\.html$ /tags.php;rewrite ^/tags/([0-9]+)\.html$ /tags.php?\/$1;rewrite ^/tags/([0-9]+)\.html$ /tags.php?\/$1\/;rewrite ^/tags/([0-9]+)_([0-9]+)\.html$ /tags.php?\/$1\/$2;rewrite ^/tags/([0-9]+)_([0-9]+)\.html$ /tags.php?\/$1\/$2\/;
web.config (iis7 iis8)
<rule name="tag首頁"><match url="^tags.html$" ignoreCase="false" /><action type="Rewrite" url="tags.php" appendQueryString="false" /></rule><rule name="tag列表"><match url="^tags/([0-9]+).html$" ignoreCase="false" /><action type="Rewrite" url="/tags.php?/{R:1}" appendQueryString="false" /></rule><rule name="tag列表最后有左斜杠"><match url="^tags/([0-9]+).html$" ignoreCase="false" /><action type="Rewrite" url="/tags.php?/{R:1}/" appendQueryString="false" /></rule><rule name="tag列表分頁"><match url="^tags/([0-9]+)_([0-9]+).html$" ignoreCase="false" /><action type="Rewrite" url="/tags.php?/{R:1}/{R:2}" appendQueryString="false" /></rule><rule name="tag列表分頁最后有左斜杠"><match url="^tags/([0-9]+)_([0-9]+).html$" ignoreCase="false" /><action type="Rewrite" url="/tags.php?/{R:1}/{R:2}/" appendQueryString="false" /></rule>
如需后臺TAG標簽管理里的TAG鏈接點擊打開也是偽靜態可這樣改

打開 /dede/templets/tags_main.htm 找到 89行
<a href="../tags.php?/<?php echo urlencode($fields['tag']); ?>/" target="_blank">{dede:field.tag /}</a>
改成
<a href="../tags/{dede:field.id /}.html" target="_blank">{dede:field.tag /}</a>
手機站TAG偽靜態實現教程
1、m 文件夾添加tags.php文件給手機站使用
2、手機站TAG標簽偽靜態規則,根據自己網站的主機環境選擇下面的規則
.htaccess (Apache 放到m文件夾下)
RewriteEngine OnRewriteBase /RewriteRule ^tags\.html$ tags\.phpRewriteRule ^tags/([0-9]+)\.html$ tags\.php\?\/$1 [L]RewriteRule ^tags/([0-9]+)\.html$ tags\.php\?\/$1\/RewriteRule ^tags/([0-9]+)_([0-9]+)\.html$ tags\.php\?\/$1\/$2RewriteRule ^tags/([0-9]+)_([0-9]+)\.html$ tags\.php\?\/$1\/$2\/
Nginx
rewrite ^/tags\.html$ /tags.php;rewrite ^/tags/([0-9]+)\.html$ /tags.php?\/$1;rewrite ^/tags/([0-9]+)\.html$ /tags.php?\/$1\/;rewrite ^/tags/([0-9]+)_([0-9]+)\.html$ /tags.php?\/$1\/$2;rewrite ^/tags/([0-9]+)_([0-9]+)\.html$ /tags.php?\/$1\/$2\/;
web.config (iis7 iis8)
<rule name="tag首頁"><match url="^tags.html$" ignoreCase="false" /><action type="Rewrite" url="tags.php" appendQueryString="false" /></rule><rule name="tag列表"><match url="^tags/([0-9]+).html$" ignoreCase="false" /><action type="Rewrite" url="/tags.php?/{R:1}" appendQueryString="false" /></rule><rule name="tag列表最后有左斜杠"><match url="^tags/([0-9]+).html$" ignoreCase="false" /><action type="Rewrite" url="/tags.php?/{R:1}/" appendQueryString="false" /></rule><rule name="tag列表分頁"><match url="^tags/([0-9]+)_([0-9]+).html$" ignoreCase="false" /><action type="Rewrite" url="/tags.php?/{R:1}/{R:2}" appendQueryString="false" /></rule><rule name="tag列表分頁最后有左斜杠"><match url="^tags/([0-9]+)_([0-9]+).html$" ignoreCase="false" /><action type="Rewrite" url="/tags.php?/{R:1}/{R:2}/" appendQueryString="false" /></rule>
3、手機站TAG標簽首頁和TAG標簽列表頁模板為
- tag_m.htm
- taglist_m.htm
4、TAG標簽調用與電腦站一樣



