当前位置:首页 > 织梦 > 关键词 > tag > 正文

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

温馨提示:DedeCMS用户请及时前往织梦官网处理官方版权事宜。
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后台更新下缓存就算搞定了.

本文属原创,转载请注明原文:https://www.zhimatong.com/jiaocheng/619.html

为保证教程的实用性及扩大知识面覆盖,如果您有相似问题而未解决,可联系在线客服免费技术支持。

内容有用

联系
顾问

在线
客服
账号登录

没有账号?立即注册

忘记密码

登录即同意用户协议没有账号? 立即注册
账号注册
我已阅读并同意用户协议
立即注册
注册即同意用户协议已有账号? 立即登录
找回密码

操作步骤:邮箱验证->设置新密码

注册即同意用户协议已有账号? 立即登录