太原網站建設詳解織夢dedecms tag設置id.html設置教程
1、在網站根目錄下的tags.php中18行找到:
if(isset($tags[2])) $PageNo = intval($tags[2]);
在其下方加入代碼:
$tagid = intval($tag);
if(!empty($tagid))
{
$row = $dsql->GetOne("SELECT tag FROM `#@__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);
$plist = str_replace('_1','',$plist);
}
4、tag 标簽僞靜态規則,請根據自己所使用的服務器環境選擇對應的規則.
.htaccess (Apache)
RewriteEngine On
RewriteBase /
RewriteRule ^tags\.html$ tags\.php
RewriteRule ^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\/$2
RewriteRule ^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)
5、後台TAG标簽管理裡的TAG鍊接修改為僞靜态(非必需,根據需要修改)
在/dede/templets/tags_main.htm文件89行找到:
{dede:field.tag /}
将其替換為:
{dede:field.tag /}
注:以上默認為PC站tag标簽僞靜态,将tag标簽的URL鍊接修改id.html的方法,如果你的網站有移動端且使用的是動态頁面,那麼你還需将移動端tag标簽的鍊接僞靜态,獨立移動端方法一樣修改對應文件即可。
,更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!