dedecms中tags标签页伪静态化修改技巧

dedecms中tags标签默认是php假伪静态功能就是如tags.php/xxxx/这种形式了,这种就是我说的假伪静态了,如果做到如/tag-abc/或tag/aaa.html这种呢,下面就来给大家介绍一下.

首先打开dedecms的/include/taglib/tag.lib.php文件,找到第87行如下这句代码:

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

将其改成如下:

$row['link'] = $cfg_cmsurl."/tags/".urlencode($row['keyword']).".html";

然后我们打开所使用模板文件夹下的taglist.htm文件,比如默认模板文件夹就是templets/default/taglist.htm,用编辑器打开在里面查找“tags.php”将其全部修改为“tags.html”

设置我们的伪静态规则,以IIS7为例,我们应该在web.config里写入如下伪静态规则:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="weather1" stopProcessing="true">
<match url="tags/([^-]+).html$" ignoreCase="true" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/tags.php?/{R:1}" appendQueryString="false" />
</rule>
<rule name="weather2" stopProcessing="true">
<match url="tags/([^-]+)-([0-9]+).html$" ignoreCase="true" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/tags.php?/{R:1}/{R:2}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

如果你是IIS6,那么就是在httpd.ini文件里加入下面这段代码:

RewriteRule ^(.*)/tags.html $1/tags.php
RewriteRule ^(.*)/tags/(.*).html $1/tags.php?$2

而Linux主机的.htaccess写法就是如下代码:

RewriteRule ^tags.html$ /tags.php
RewriteRule ^tags/(.*).html$ /tags.php?/$1/

我们进入dedecms后台更新下缓存就算搞定了.

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

给TA打赏
共{{data.count}}人
人已打赏
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索