景惠 發表於 2023-10-6 00:00:00

织梦Dedecms设置伪静态详细方法

<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        首先在dede后台开启伪静态(开启的方法在系统参数-核心设置)</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        第一步. 首先栏目和文章最好设置成动态浏览. 这样才不会生成静态html文件.<br>
        第二步. 设置重写规则. 在系统目录下加一个 .htaccess文件. 内容为:</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </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>
        <p>
                代码如下:</p>
</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";'>
        <br>
        RewriteEngine On<br>
        RewriteRule ^plus/list-(+).html$ /plus/list.php?tid=$1<br>
        RewriteRule ^plus/list-(+)-(+)-(+).html$ /plus/list.php?tid=$1&amp;totalresult=$2&amp;PageNo=$3<br>
        RewriteRule ^plus/view-(+)-1.html$ /plus/view.php?arcID=$1<br>
        RewriteRule ^plus/view-(+)-(+).html$ /plus/view.php?aid=$1&amp;pageno=$2</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";'>
        iis文件写法<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>
        <p>
                代码如下:</p>
</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";'>
        <br>
        #首页伪静态规则,如果不使用动态首页,请勿必删除这一行,否则打开首页会出现死循环<br>
        RewriteRule ^(.*)/index.html $1/index.php <br>
        #列表页伪静态规则<br>
        RewriteRule ^(.*)/category/list-(+).html $1/plus/list.php?tid=$2 <br>
        RewriteRule ^(.*)/category/list-(+)-(+)-(+).html $1/plus/list.php?tid=$2&amp;amp;TotalResult=$3&amp;amp;PageNo=$4 <br>
        #文章页伪静态规则<br>
        RewriteRule ^(.*)/archives/view-(+)-(+).html $1/plus/view.php?arcID=$2&amp;amp;pageno=$3 <br>
        #搜索伪静态规则<br>
        RewriteRule ^(.*)/search.html(?:(?.*))* $1/search.php?$2 <br>
        #TAG标签伪静态规则<br>
        RewriteRule ^(.*)/tags.html $1/tags.php <br>
        RewriteRule ^(.*)/tags/(.*)(?:(?.*))* $1/tags.php?/$2 <br>
        RewriteRule ^(.*)/tags/(.*)/(?:(?.*))* $1/tags.php?/$2/ <br>
        RewriteRule ^(.*)/tags/(.*)/()(?:(?.*))* $1/tags.php?/$2/$3 <br>
        RewriteRule ^(.*)/tags/(.*)/()/(?:(?.*))* $1/tags.php?/$2/$3/ </div>
<p>
        <br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>如果你的系统支持url重写,到这里就可以用伪静态访问了.</span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>第三步.更改重写的URL.</span></p>
<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";'>
        如果用默认的设置, 访问的URL是:<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>
        <p>
                代码如下:</p>
</div>
<div class="msgborder" id="phpcode14" 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";'>
        <br>
        http://www.XXXX.com/plus/view-131-1.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";'>
        这样的形色, 我们是可以更改这种样式的.</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        找到文件/include/helpers/channelunit.helper.php打开.</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>
        <p>
                代码如下:</p>
</div>
<div class="msgborder" id="phpcode15" 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";'>
        <br>
        return $GLOBALS["cfg_plus_dir"]."/view-".$aid.'-1.html';<br>
        这就是文章的url形色.<br>
        $reurl = $GLOBALS['cfg_phpurl']."/list.php?tid=".$typeid;</div>
<p>
        <br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>这是列表的重写url.</span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>可以使url更短一点,完成可以写成:</span></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>
        <p>
                代码如下:</p>
</div>
<div class="msgborder" id="phpcode16" 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";'>
        <br>
        return "/view-".$aid.'-1.html';<br>
        和<br>
        $reurl = "/list-".$typeid.".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";'>
        这时重写规则也要更新.<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>
        <p>
                代码如下:</p>
</div>
<div class="msgborder" id="phpcode17" 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";'>
        <br>
        RewriteEngine On<br>
        RewriteRule ^list-(+).html$ /plus/list.php?tid=$1<br>
        RewriteRule ^list-(+)-(+)-(+).html$ /plus/list.php?tid=$1&amp;totalresult=$2&amp;PageNo=$3<br>
        RewriteRule ^view-(+)-1.html$ /plus/view.php?arcID=$1<br>
        RewriteRule ^view-(+)-(+).html$ /plus/view.php?aid=$1&amp;pageno=$2</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";'>
        更进一步,还可以把view换成自己的任何词语,这也要把include/arc.archives.class.php文件中的view也一样替换。<br>
        发布选项: 生成HTML 仅动态浏览 发文章的时候选一下也不多事。为了以后升级 尽量减少修改文件。<br>
        以下这没有试,大家按需要测试吧~~</p>
<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>
        <p>
                代码如下:</p>
</div>
<div class="msgborder" id="phpcode18" 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";'>
        <br>
        update dede_archives set ismake=-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";'>
        并将ismake的默认值设置为 -1即动态。</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>
        <p>
                代码如下:</p>
</div>
<div class="msgborder" id="phpcode19" 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";'>
        <br>
        update dede_arctype set isdefault=-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";'>
        DedeCmsTAG标签伪静态</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        DedeCms默认的TAG标签URL,形如/tags.php?/dedecms5.7/,非常之难看。打开/include/taglib/tag.lib.php,找到lib_tag()函数下的:<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>
        <p>
                代码如下:</p>
</div>
<div class="msgborder" id="phpcode20" 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";'>
        <br>
        $row['link'] = $cfg_cmsurl."/tags.php?/".urlencode($row['keyword'])."/";<br>
        替换为<br>
        $row['link'] = $cfg_cmsurl."/tags/".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>
        我们需要修改include/arc.taglist.class.php,将分页函数替换为:<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>
        <p>
                代码如下:</p>
</div>
<div class="msgborder" id="phpcode21" 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";'>
        <br>
        /** * 获取动态的分页列表<br>
        *<br>
        * @access public<br>
        * @param int $list_len 列表宽度<br>
        * @param string $listitem 列表样式<br>
        * @return string<br>
        */<br>
        function GetPageListDM($list_len,$listitem="info,index,end,pre,next,pageno")<br>
        {<br>
        $prepage="";<br>
        $nextpage="";<br>
        $prepagenum = $this-&gt;PageNo - 1;<br>
        $nextpagenum = $this-&gt;PageNo + 1;<br>
        if($list_len == "" || preg_match("/[^0-9]/", $list_len))<br>
        {<br>
        $list_len = 3;<br>
        }<br>
        $totalpage = $this-&gt;TotalPage;<br>
        if($totalpage &lt;= 1 &amp;&amp; $this-&gt;TotalResult &gt; 0)<br>
        {<br>
        return "&lt;span class="pageinfo"&gt;共1页/".$this-&gt;TotalResult."条&lt;/span&gt;";<br>
        }<br>
        if($this-&gt;TotalResult == 0)<br>
        {<br>
        return "&lt;span class="pageinfo"&gt;共0页/".$this-&gt;TotalResult."条&lt;/span&gt;";<br>
        }<br>
        $maininfo = "&lt;span class="pageinfo"&gt;共{$totalpage}页/".$this-&gt;TotalResult."条&lt;/span&gt;rn";<br>
        $purl = $this-&gt;GetCurUrl();<br>
        $basename = basename($purl);<br>
        $tmpname = explode('.', $basename);<br><br>
        $purl = str_replace($basename, '', $purl).urlencode($this-&gt;Tag);<br>
        //var_dump($purl);exit;<br>
        //$purl .= "?/".urlencode($this-&gt;Tag);<br><br>
        //获得上一页和下一页的链接<br>
        if($this-&gt;PageNo != 1)<br>
        {<br>
        $prepage.="&lt;li&gt;&lt;a href='".$purl."-$prepagenum'.html&gt;上一页&lt;/a&gt;&lt;/li&gt;rn";<br>
        $indexpage="&lt;li&gt;&lt;a href='".$purl."-1.html'&gt;首页&lt;/a&gt;&lt;/li&gt;rn";<br>
        }<br>
        else<br>
        {<br>
        $indexpage="&lt;li&gt;&lt;a&gt;首页&lt;/a&gt;&lt;/li&gt;rn";<br>
        }<br>
        if($this-&gt;PageNo!=$totalpage &amp;&amp; $totalpage&gt;1)<br>
        {<br>
        $nextpage.="&lt;li&gt;&lt;a href='".$purl."-$nextpagenum.html'&gt;下一页&lt;/a&gt;&lt;/li&gt;rn";<br>
        $endpage="&lt;li&gt;&lt;a href='".$purl."-$totalpage.html'&gt;末页&lt;/a&gt;&lt;/li&gt;rn";<br>
        }<br>
        else<br>
        {<br>
        $endpage="&lt;li&gt;&lt;a&gt;末页&lt;/a&gt;&lt;/li&gt;rn";<br>
        }<br><br>
        //获得数字链接<br>
        $listdd="";<br>
        $total_list = $list_len * 2 + 1;<br>
        if($this-&gt;PageNo &gt;= $total_list)<br>
        {<br>
        $j = $this-&gt;PageNo - $list_len;<br>
        $total_list = $this-&gt;PageNo + $list_len;<br>
        if($total_list &gt; $totalpage)<br>
        {<br>
        $total_list = $totalpage;<br>
        }<br>
        }<br>
        else<br>
        {<br>
        $j=1;<br>
        if($total_list &gt; $totalpage)<br>
        {<br>
        $total_list = $totalpage;<br>
        }<br>
        }<br>
        for($j; $j&lt;=$total_list; $j++)<br>
        {<br>
        if($j == $this-&gt;PageNo)<br>
        {<br>
        $listdd.= "&lt;li class="thisclass"&gt;&lt;a&gt;$j&lt;/a&gt;&lt;/li&gt;rn";<br>
        }<br>
        else<br>
        {<br>
        $listdd.="&lt;li&gt;&lt;a href='".$purl."-$j.html'&gt;".$j."&lt;/a&gt;&lt;/li&gt;rn";<br>
        }<br>
        }<br>
        $plist = '';<br>
        if(preg_match('/info/i', $listitem))<br>
        {<br>
        $plist .= $maininfo.' ';<br>
        }<br>
        if(preg_match('/index/i', $listitem))<br>
        {<br>
        $plist .= $indexpage.' ';<br>
        }<br>
        if(preg_match('/pre/i', $listitem))<br>
        {<br>
        $plist .= $prepage.' ';<br>
        }<br>
        if(preg_match('/pageno/i', $listitem))<br>
        {<br>
        $plist .= $listdd.' ';<br>
        }<br>
        if(preg_match('/next/i', $listitem))<br>
        {<br>
        $plist .= $nextpage.' ';<br>
        }<br>
        if(preg_match('/end/i', $listitem))<br>
        {<br>
        $plist .= $endpage.' ';<br>
        }<br>
        return $plist;<br>
        }</div>
頁: [1]
查看完整版本: 织梦Dedecms设置伪静态详细方法