• dedecms tag 伪静态 数字版本


    织梦伪静态将tag标签的url设置成id的方法:
    1、在网站根目录下的tags.php中18行找到:

    if(isset($tags[2])) $PageNo = intval($tags[2]);
    
    • 1

    在其下方加入代码:

    $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 = '';
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    2、/include/taglib/tag.lib.php 87行找到:

    $row['link'] = $cfg_cmsurl."/tags.php?/".urlencode($row['keyword'])."/";
    
    • 1

    将其替换成:

    $row['link'] = $cfg_cmsurl."/tags/".$row['id'].".html";
    
    • 1

    3、/include/arc.taglist.class.php 458行找到:

    $purl .= "?/".urlencode($this->Tag);
    
    • 1

    将其替换成:

    if(!defined('DEDERETAG'))
    {
    	$purl .= "?/".urlencode($this->Tag);
    }
    
    • 1
    • 2
    • 3
    • 4

    继续在这个文件里找到:

    return $plist;
    
    • 1

    在其上方加入代码:

    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);
            }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    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/
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    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/;
    
    • 1
    • 2
    • 3
    • 4
    • 5

    web.config (iis7 iis8)

    
    	
    	
    
    
    	
    	
    
    
    	
    	
    
    
    	
    	
    
    
    	
    	
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20

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

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

    {dede:field.tag /}
    
    • 1

    将其替换为:

    {dede:field.tag /}
    
    • 1

    注:以上默认为PC站tag标签伪静态,将tag标签的URL链接修改id.html的方法

  • 相关阅读:
    图像标签的使用2
    物理学史----热力学发展史概要
    高通平台Android 蓝牙调试和配置手册-- SCO Audio Quality Issues
    PyTorch 迭代器读取数据
    DirectX11 With Windows SDK--40 抗锯齿:FXAA
    springboot AOP记录操作日志(包含遇到的问题)
    谈一谈对 Android Context 的理解
    【Leetcode】1210. Minimum Moves to Reach Target with Rotations
    【教学类-13-05】20240604《数字色块图-5*7*8-A4横板-横切》中4班
    类加载器分类以及著名的双亲委派机制
  • 原文地址:https://blog.csdn.net/wei741094234/article/details/133125245