女子豹变 發表於 2024-2-29 00:00:00

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

<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        本文实例讲述了dedecms中tags标签页伪静态化修改技巧。分享给大家供大家参考。具体分析如下:</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        dedecms中tags标签默认是php假伪静态功能就是如tags.php/xxxx/这种形式了,这种就是我说的假伪静态了,如果做到如/tag-abc/或tag/aaa.html这种呢,下面就来给大家介绍一下.</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        首先打开dedecms的/include/taglib/tag.lib.php文件,找到第87行如下这句代码,代码如下:<br>
         </p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode9" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        $row['link'] = $cfg_cmsurl."/tags.php?/".urlencode($row['keyword'])."/";</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        将其改成如下:<br>
         </p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode10" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        $row['link'] = $cfg_cmsurl."/tags/".urlencode($row['keyword']).".html";</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        然后我们打开所使用模板文件夹下的taglist.htm文件,比如默认模板文件夹就是templets/default/taglist.htm,用编辑器打开在里面查找“tags.php”将其全部修改为“tags.html”</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        最后来设置我们的伪静态规则,以IIS7为例,我们应该在web.config里写入如下伪静态规则,代码如下:<br>
         </p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode11" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        &lt;?xml version="1.0" encoding="UTF-8"?&gt; <br>
        &lt;configuration&gt; <br>
        &lt;system.webServer&gt; <br>
        &lt;rewrite&gt; <br>
        &lt;rules&gt; <br>
        &lt;rule name="weather1" stopProcessing="true"&gt; <br>
        &lt;match url="tags/([^-]+).html$" ignoreCase="true" /&gt; <br>
        &lt;conditions logicalGrouping="MatchAll"&gt; <br>
        &lt;add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /&gt; <br>
        &lt;add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /&gt; <br>
        &lt;/conditions&gt; <br>
        &lt;action type="Rewrite" url="/tags.php?/{R:1}" appendQueryString="false" /&gt; <br>
        &lt;/rule&gt; <br>
        &lt;rule name="weather2" stopProcessing="true"&gt; <br>
        &lt;match url="tags/([^-]+)-(+).html$" ignoreCase="true" /&gt; <br>
        &lt;conditions logicalGrouping="MatchAll"&gt; <br>
        &lt;add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /&gt; <br>
        &lt;add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /&gt; <br>
        &lt;/conditions&gt; <br>
        &lt;action type="Rewrite" url="/tags.php?/{R:1}/{R:2}" appendQueryString="false" /&gt; <br>
        &lt;/rule&gt; <br>
        &lt;/rules&gt; <br>
        &lt;/rewrite&gt; <br>
        &lt;/system.webServer&gt; <br>
        &lt;/configuration&gt;</div>
<br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>如果你是IIS6,那么就是在httpd.ini文件里加入下面这段代码:</span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode12" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        RewriteRule ^(.*)/tags.html $1/tags.php<br>
        RewriteRule ^(.*)/tags/(.*).html $1/tags.php?$2</div>
<br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>而Linux主机的.htaccess写法就是如下代码:</span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode13" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        RewriteRule ^tags.html$ /tags.php<br>
        RewriteRule ^tags/(.*).html$ /tags.php?/$1/</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        最后我们进入dedecms后台更新下缓存就算搞定了.</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        希望本文所述对大家的dedecms建站有所帮助。</p>
頁: [1]
查看完整版本: dedecms中tags标签页伪静态化修改技巧