织梦dedecms tag设置id.html教程-kb88凯时官网登录

时间:2021-01-27
阅读:
免费资源网 - https://freexyz.cn/

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标签的链接伪静态,独立移动端方法一样修改对应文件即可。

免费资源网 - https://freexyz.cn/
返回顶部
顶部
网站地图