温馨提醒

如果文章内容或图片资源失效,请留言反馈,我们会及时处理,谢谢

本文最后更新于2023年11月15日,已超过 180天没有更新

1、在网站根目录下的tags.php中18行找到:

$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)

<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>

5、后台TAG标签管理里的TAG链接修改为伪静态(非必需,根据需要修改)

在/dede/templets/tags_main.htm文件89行找到:

/" target="_blank" _href="../tags.php?//">{dede:field.tag /}

将其替换为:

{dede:field.tag /}

 

历史上的今天
11月
15
    抱歉,历史上的今天作者很懒,什么都没写!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。