Dedecms织梦系统电脑站手机站TAG标签伪静态

Dedecms织梦系统电脑站手机站TAG标签伪静态,不管网站全站是静态或者动态还是伪静态,此织梦教程都可以设置TAG标签页为伪静态,并且是单链接拼音的形式

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

例:
TAG标签首页 https://www.yunbuluo.com/tags.html
TAG标签列表 https://www.yunbuluo.com/tag/zhimeng.html
TAG标签分页 https://www.yunbuluo.com/tag/zhimeng_2.html
按此教程操作后,手机站TAG标签url会像如下:
TAG标签首页 http://m.yunbuluo.com/tags.html
TAG标签列表 http://m.yunbuluo/tags/zhimeng.html
TAG标签分页 http://m.yunbuluo.com/tags/zhimeng_2.html
电脑站TAG伪静态实现教程
1、后台-系统-SQL命令行工具-执行

ALTER TABLE `58pic_tagindex` ADD `filename` CHAR( 255 ) NOT NULL DEFAULT ”;
2、对TAG标签表已有数据的拼音字段生成拼音

点击下面链接下载文件,根据自己程序编码,选择pinyin.php文件,放到网站根目录

链接: https://pan.baidu.com/s/1J0WsmakMBTTPPHSlaB3Otw 提取码: cxcn

pinyin.php放到网站根目录后,在浏览器上打开

http://你的域名/pinyin.php
打开后文件会自动对已有的TAG标签生成拼音,完成即可,完成后删除这个文件

以后添加文档或者TAG标签后不再需要执行它了,第3步是为了以后的TAG自动生成拼音。

3、/include/helpers/archive.helper.php 找到

$tid = $dsql->GetLastID();
在它下面加入

$pinyin = GetPinyin($tag);
$shuzi = ”;
$fnrow = $dsql->GetOne(“SELECT id FROM `58pic_tagindex` WHERE filename LIKE ‘$pinyin’ ORDER BY id DESC LIMIT 1”);
if(is_array($fnrow))
{
$strarr = str_split($pinyin);
$strend = $strarr[count($strarr) – 1];
$shuzi = is_numeric($strend) ? $strend+1 : 1;
}
$upquery = “UPDATE `58pic_tagindex` SET `filename`='{$pinyin}{$shuzi}’ WHERE id=’$tid’ “;
$dsql->ExecuteNoneQuery($upquery);
4、/tags.php 找到 25行

$tag = FilterSearch(urldecode($tag));
在它上面加入

$tag = reset(explode(“_”, $tag));
$PageNo = stripos(GetCurUrl(), ‘.html’) ? intval(str_replace(‘.html’, ”, end(explode(“_”, GetCurUrl())))) : 1;
$row = $dsql->GetOne(“SELECT tag FROM `58pic_tagindex` WHERE filename = ‘$tag’ ORDER BY id DESC LIMIT 1″);
if(is_array($row))
{
$tag = $row[‘tag’];
define(‘DEDERETAG’, ‘Y’);
}
5、/include/taglib/tag.lib.php 找到 87行

$row[‘link’] = $cfg_cmsurl.”/tags.php?/”.urlencode($row[‘keyword’]).”/”;
改成

$row[‘link’] = $cfg_cmsurl.”/tags/”.GetPinyin($row[‘tag’]).”.html”;
6、/include/arc.taglist.class.php 找到 121行

$this->PageNo = $GLOBALS[‘PageNo’];
在它下面加入

if($this->PageNo == 0)
{
$this->PageNo = 1;
}
继续找到

$purl .= “?/”.urlencode($this->Tag);
改成

if(!defined(‘DEDERETAG’))
{
$purl .= “?/”.urlencode($this->Tag);
}
else
{
$purl = $cfg_cmsurl.”/tags/”.GetPinyin($this->Tag);
}
继续找到

return $plist;
在它上面加入

if(defined(‘DEDERETAG’))
{
$plist = str_replace(‘.html’, ”, $plist);
$plist = preg_replace(“/\/(\d+)\//i”,’_\\1.html’,$plist);
$plist = preg_replace(“/PageNo=(\d+)/i”,’_\\1.html’,$plist);
}
7、电脑站TAG标签伪静态规则,根据自己网站的主机环境选择下面的规则

.htaccess (Apache)

RewriteEngine On
RewriteBase /
RewriteRule ^tags\.html$ tags\.php
RewriteRule ^tags/(.*)_([0-9]+)\.html$ tags\.php\?\/$1\/$2 [L]
RewriteRule ^tags/(.*)_([0-9]+)\.html$ tags\.php\?\/$1\/$2\/ [L]
RewriteRule ^tags/(.*)\.html$ tags\.php\?\/$1
RewriteRule ^tags/(.*)\.html$ tags\.php\?\/$1\/
Nginx

rewrite ^/tags\.html$ /tags.php;
rewrite ^/tags/(.*)-([0-9]+)\.html$ /tags.php?\/$1\/$2;
rewrite ^/tags/(.*)\.html$ /tags.php?\/$1;
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}/{R:2}” appendQueryString=”false” />
</rule>
<rule name=”tag列表分页最后有左斜杠”>
<match url=”^tags/(.*)_([0-9]+).html$” ignoreCase=”false” />
<action type=”Rewrite” url=”/tags.php?/{R:1}/{R:2}/” appendQueryString=”false” />
</rule>
<rule name=”tag列表”>
<match url=”^tags/(.*).html$” ignoreCase=”false” />
<action type=”Rewrite” url=”/tags.php?/{R:1}” appendQueryString=”false” />
</rule>
<rule name=”tag列表最后有左斜杠”>
<match url=”^tags/(.*).html$” ignoreCase=”false” />
<action type=”Rewrite” url=”/tags.php?/{R:1}/” 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/<?php echo GetPinyin($fields[‘tag’]); ?>.html” target=”_blank”>{dede:field.tag /}</a>
手机站TAG伪静态实现教程
1、m 文件夹添加tags.php文件给手机站使用

链接: https://pan.baidu.com/s/1-ZxiwDw787v7SkgKrY-cYA 提取码: 8vf4

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

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

RewriteEngine On
RewriteBase /
RewriteRule ^tags\.html$ tags\.php
RewriteRule ^tags/(.*)_([0-9]+)\.html$ tags\.php\?\/$1\/$2 [L]
RewriteRule ^tags/(.*)_([0-9]+)\.html$ tags\.php\?\/$1\/$2\/ [L]
RewriteRule ^tags/(.*)\.html$ tags\.php\?\/$1
RewriteRule ^tags/(.*)\.html$ tags\.php\?\/$1\/
Nginx

rewrite ^/tags\.html$ /tags.php;
rewrite ^/tags/(.*)-([0-9]+)\.html$ /tags.php?\/$1\/$2;
rewrite ^/tags/(.*)\.html$ /tags.php?\/$1;
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}/{R:2}” appendQueryString=”false” />
</rule>
<rule name=”tag列表分页最后有左斜杠”>
<match url=”^tags/(.*)_([0-9]+).html$” ignoreCase=”false” />
<action type=”Rewrite” url=”/tags.php?/{R:1}/{R:2}/” appendQueryString=”false” />
</rule>
<rule name=”tag列表”>
<match url=”^tags/(.*).html$” ignoreCase=”false” />
<action type=”Rewrite” url=”/tags.php?/{R:1}” appendQueryString=”false” />
</rule>
<rule name=”tag列表最后有左斜杠”>
<match url=”^tags/(.*).html$” ignoreCase=”false” />
<action type=”Rewrite” url=”/tags.php?/{R:1}/” appendQueryString=”false” />
</rule>
3、手机站TAG标签首页和TAG标签列表页模板为

tag_m.htm
taglist_m.htm
4、TAG标签调用与电脑站一样,想要了解更多内容请关注云部落(Yunbuluo.Net)资源网其它相关文章!

本站部分素材资源及板块内容来自网络,如有侵犯您的权益,请联系我们,站长会立即处理,转载请注明来源网址!
云部落资源网 » Dedecms织梦系统电脑站手机站TAG标签伪静态