织梦电脑站手机站TAG标签伪静态-单链接id版

摘要:无论你网站全站是静态或者动态还是伪静态,此教程都可以设置TAG标签页为伪静态,并且是单链接id的形式 按此教程操作后,电脑站TAG标签url会像如下: TAG标签首页 http://www.zmzmb.com/tags.html T

无论你网站全站是静态或者动态还是伪静态,此教程都可以设置TAG标签页为伪静态,并且是单链接id的形式

按此教程操作后,电脑站TAG标签url会像如下:

  • TAG标签首页 http://www.zmzmb.com/tags.html
  • TAG标签列表 http://www.zmzmb.com/tags/9.html
  • TAG标签分页 http://www.zmzmb.com/tags/9_2.html

按此教程操作后,手机站TAG标签url会像如下:

  • TAG标签首页 http://m.zmzmb.com/tags.html
  • TAG标签列表 http://m.zmzmb.com/tags/9.html
  • TAG标签分页 http://m.zmzmb.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 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>

如需后台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文件给手机站使用

链接: https://pan.baidu.com/s/1ZpG1om3e90JwoIQmiymsgw 提取码: nivw

2、手机站TAG标签伪静态规则,根据自己网站的主机环境选择下面的规则

.htaccess (Apache 放到m文件夹下)

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>

3、手机站TAG标签首页和TAG标签列表页模板为

  • tag_m.htm
  • taglist_m.htm

4、TAG标签调用与电脑站一样

版权声明:本文为本站原创文章,未经本站允许不得转载。https://www.zmzmb.com/study/dede/934.html

织梦DEDECMS首页列表页调用文章TAG标签的方法

追梦者模板 8

1.如果是dedecms v5.7版本直接使用标签 [field:id function=GetTags(@me)/] 就可以调用出来了。只不过不带连接的。 2.如果需要连接请注释掉include/helpers/archive.helper.php文件的130行, $tags .= ($tags=='' ? $row['

织梦tag提示“系统无此标签,可能已经移除”的解决方法

追梦者模板 8

今天在开发新网站搜索标签的时候,居然有2个标签提示系统无此标签,可能已经移除..但是标签确实存在在系统中 然后我的这两个标签包含大写 SEO推广 和 SEO优化.. 所以需要改下代码 找到根目录

织梦模板标记简介

追梦者模板 8

在了解DedeCms的模板代码之前,了解一下 织梦模板 引擎的知识是非常有意义的。 织梦模板 引擎是一种使用XML名字空间形式的模板解析器,使用织梦解析器解析模板的最大好处是可以轻松的制定