织梦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&totalresult=$2&PageNo=$3<br>
RewriteRule ^plus/view-(+)-1.html$ /plus/view.php?arcID=$1<br>
RewriteRule ^plus/view-(+)-(+).html$ /plus/view.php?aid=$1&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;TotalResult=$3&amp;PageNo=$4 <br>
#文章页伪静态规则<br>
RewriteRule ^(.*)/archives/view-(+)-(+).html $1/plus/view.php?arcID=$2&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&totalresult=$2&PageNo=$3<br>
RewriteRule ^view-(+)-1.html$ /plus/view.php?arcID=$1<br>
RewriteRule ^view-(+)-(+).html$ /plus/view.php?aid=$1&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->PageNo - 1;<br>
$nextpagenum = $this->PageNo + 1;<br>
if($list_len == "" || preg_match("/[^0-9]/", $list_len))<br>
{<br>
$list_len = 3;<br>
}<br>
$totalpage = $this->TotalPage;<br>
if($totalpage <= 1 && $this->TotalResult > 0)<br>
{<br>
return "<span class="pageinfo">共1页/".$this->TotalResult."条</span>";<br>
}<br>
if($this->TotalResult == 0)<br>
{<br>
return "<span class="pageinfo">共0页/".$this->TotalResult."条</span>";<br>
}<br>
$maininfo = "<span class="pageinfo">共{$totalpage}页/".$this->TotalResult."条</span>rn";<br>
$purl = $this->GetCurUrl();<br>
$basename = basename($purl);<br>
$tmpname = explode('.', $basename);<br><br>
$purl = str_replace($basename, '', $purl).urlencode($this->Tag);<br>
//var_dump($purl);exit;<br>
//$purl .= "?/".urlencode($this->Tag);<br><br>
//获得上一页和下一页的链接<br>
if($this->PageNo != 1)<br>
{<br>
$prepage.="<li><a href='".$purl."-$prepagenum'.html>上一页</a></li>rn";<br>
$indexpage="<li><a href='".$purl."-1.html'>首页</a></li>rn";<br>
}<br>
else<br>
{<br>
$indexpage="<li><a>首页</a></li>rn";<br>
}<br>
if($this->PageNo!=$totalpage && $totalpage>1)<br>
{<br>
$nextpage.="<li><a href='".$purl."-$nextpagenum.html'>下一页</a></li>rn";<br>
$endpage="<li><a href='".$purl."-$totalpage.html'>末页</a></li>rn";<br>
}<br>
else<br>
{<br>
$endpage="<li><a>末页</a></li>rn";<br>
}<br><br>
//获得数字链接<br>
$listdd="";<br>
$total_list = $list_len * 2 + 1;<br>
if($this->PageNo >= $total_list)<br>
{<br>
$j = $this->PageNo - $list_len;<br>
$total_list = $this->PageNo + $list_len;<br>
if($total_list > $totalpage)<br>
{<br>
$total_list = $totalpage;<br>
}<br>
}<br>
else<br>
{<br>
$j=1;<br>
if($total_list > $totalpage)<br>
{<br>
$total_list = $totalpage;<br>
}<br>
}<br>
for($j; $j<=$total_list; $j++)<br>
{<br>
if($j == $this->PageNo)<br>
{<br>
$listdd.= "<li class="thisclass"><a>$j</a></li>rn";<br>
}<br>
else<br>
{<br>
$listdd.="<li><a href='".$purl."-$j.html'>".$j."</a></li>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]