dedecms中tags标签页伪静态化修改技巧
本文实例讲述了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>
<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
RewriteRule ^(.*)/tags/(.*).html $1/tags.php?$2
而Linux主机的.htaccess写法就是如下代码:
RewriteRule ^tags.html$ /tags.php
RewriteRule ^tags/(.*).html$ /tags.php?/$1/
RewriteRule ^tags/(.*).html$ /tags.php?/$1/
最后我们进入dedecms后台更新下缓存就算搞定了.
希望本文所述对大家的dedecms建站有所帮助。
本文由主机测评网发布,不代表主机测评网立场,转载联系作者并注明出处:https://zhuji.jb51.net/dedecms/3794.html