无论你网站全站是静态或者动态还是伪静态,此教程都可以设置TAG标签页为伪静态,并且是单链接拼音的形式,另外两种形式参考《dedecms织梦tag标签url拼音化的修改方法(单链接名称拼音版)》和《织梦电脑站手机站TAG标签伪静态-单链接id版》
按此教程操作后,电脑站TAG标签url会像如下:
TAG标签首页 http://www.abc.com/tags/
TAG标签列表 http://www.abc.com/tags/list/
TAG标签分页 http://www.abc.com/tags/list_2/
按此教程操作后,手机站TAG标签url会像如下:
TAG标签首页 http://m.abc.com/tags/
TAG标签列表 http://m.abc.com/tags/list/
TAG标签分页 http://m.abc.com/tags/list_2/
电脑站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 OnRewriteBase /RewriteRule ^tags\.html$tags\.phpRewriteRule ^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\/$2RewriteRule ^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.
本文共 228 个字数,平均阅读时长 ≈ 1分钟
评论 (0)