Seize the day, enjoy my life! 注册 | 登陆

DEDECMS全站?静???教程(首?、列表、文章?)

本人比??,相信不少朋友也是,?得?次去生成dedecms的HTML,同??了?已不太有效的?静??化,所以?是搞搞?静?吧。

dedecms全站?静?教程分?五部分,包括“Apache?置、.htaccess文件?置、首??静?、列表??静?、文章??静?”。

用4.0??OK,5.X没?。

一、Apache文件?置

?是重??,以前用本地???因 httpd.conf 文件没?置好,搞得焦???。

1、如果是虚?主机,一般 apache 的 LoadModule rewrite_module modules/mod_rewrite.so 是?启的,?咨?你的主机提供商以确?是否支持?静?。

2、如果是自己的服?器或本地机器,?按以下?置:

?? apache 服?。

打? httpd.conf 文件(一般放在apache安装目?的conf目?下)把 #LoadModule rewrite_module modules/mod_rewrite.so 前的 # 号去掉,代表?启 rewrite ??。

搜索 “AllowOverride None”(不包括引号,下同) ,有多个,全部替?? “AllowOverride All”。

?启 apache 服?。

二、.htaccess文件?置

在网站根目?建一 .htaccess 文件,内容?:

RewriteEngine On
RewriteBase /
RewriteRule ^(.*)index\.html$ $1/index.php
RewriteRule ^(.*)list-([0-9]+)\.html$ $1/plus/list.php?tid=$2
RewriteRule ^(.*)list-([0-9]+)-([0-9]+)\.html$ $1/plus/list.php?typeid=$2&PageNo=$3
RewriteRule ^(.*)view-([0-9]+).html$ $1/plus/view.php?aid=$2
RewriteRule ^(.*)view-([0-9]+)-([0-9]+).html$ $1/plus/view.php?aid=$2&pageno=$3

三、dedecms首??静?

不要更新首?html就行。如果已更新,??除index.html即可。

四、dedecms列表??静?

1、打? /include/inc_arclist_view.php 找到

  //---------------------------------
  //?取??的分?列表
  //---------------------------------

把它下面的函数改成以下的:

function GetPageListDM($list_len,$listitem="index,end,pre,next,pageno")
    {
        $prepage="";
        $nextpage="";
        $prepagenum = $this->PageNo-1;
        $nextpagenum = $this->PageNo+1;
        if($list_len==""||ereg("[^0-9]",$list_len)) $list_len=3;
        $totalpage = ceil($this->TotalResult/$this->PageSize);
        if($totalpage<=1 && $this->TotalResult>0) return "共1?/".$this->TotalResult."条??";
        if($this->TotalResult == 0) return "共0?".$this->TotalResult."条??";
        $maininfo = "共{$totalpage}?/".$this->TotalResult."条??";
       
        $purl = $this->GetCurUrl();
        $geturl = "typeid=".$this->TypeID."&TotalResult=".$this->TotalResult."&";
        $gettypeid =$this->TypeID."-";
        //$hidenform = "<input type='hidden' name='typeid' value='".$this->TypeID."'>";
        //$hidenform .= "<input type='hidden' name='TotalResult' value='".$this->TotalResult."'>";
       
        $purl .= "?".$geturl;
       
        //?得上一?和下一?的?接
        if($this->PageNo != 1){
            $prepage.="<a href='list-".$gettypeid."$prepagenum.html'>上一?</a>";
            $indexpage="<a href='list-".$gettypeid."1.html'>首?</a>";
        }
        else{
            $indexpage="首?";
        }   
       
        if($this->PageNo!=$totalpage && $totalpage>1){
            $nextpage.="<a href='list-".$gettypeid."$nextpagenum.html'>下一?</a>";
            $endpage="<a href='list-".$gettypeid."$totalpage.html'>末?</a>";
        }
        else{
            $endpage="末?";
        }
        //?得数字?接
        $listdd="";
        $total_list = $list_len * 2 + 1;
        if($this->PageNo >= $total_list) {
            $j = $this->PageNo-$list_len;
            $total_list = $this->PageNo+$list_len;
            if($total_list>$totalpage) $total_list=$totalpage;
        }else{
              $j=1;
              if($total_list>$totalpage) $total_list=$totalpage;
        }
        for($j;$j<=$total_list;$j++){
          $listdd.="<a href='list-".$gettypeid."$j.html'>".$j."</a>";
        }
        $plist .= $maininfo.$indexpage.$prepage.$listdd.$nextpage.$endpage;
        return $plist;
    }

2、打? /include/inc_channel_unit_functions.php ?找

    $reurl = $GLOBALS["cfg_plus_dir"]."/list.php?tid=".$typeid;

改成

    $reurl = "/list-".$typeid.".html"; //列表??静?

五、dedecms文章??静?

1、打? /include/inc_archives_view.php ,有两?修改的地方,

1.1 找到:

         //------------------------
         //?得???面分?列表
         //------------------------
   function GetPagebreakDM($totalPage,$nowPage,$aid)
        {
                if($totalPage==1){ return ""; }
                $PageList = "共".$totalPage."?: ";
                $nPage = $nowPage-1;
                $lPage = $nowPage+1;
                if($nowPage==1) $PageList.="上一? ";
                else{
                  if($nPage==1) $PageList.="<a href='view.php?aid=$aid'>上一?</a> ";
                  else $PageList.="<a href='view.php?aid=$aid&pageno=$nPage'>上一?</a> ";
                }
                for($i=1;$i<=$totalPage;$i++)
                {
                        if($i==1){
                          if($nowPage!=1) $PageList.="<a href='view.php?aid=$aid'>[1]</a> ";
                          else $PageList.="1 ";
                        }else{
                          $n = $i;
                          if($nowPage!=$i) $PageList.="<a href='view.php?aid=$aid&pageno=$i'>[".$n."]</a> ";
                          else $PageList.="$n ";
                        }
                }
                if($lPage <= $totalPage) $PageList.="<a href='view.php?aid=$aid&pageno=$lPage'>下一?</a> ";
                else $PageList.= "下一? ";
                return $PageList;
        }

修改?:

  //?得?静??面分?列表
   function GetPagebreakDM($totalPage,$nowPage,$aid)
        {
                if($totalPage==1){ return ""; }
                $PageList = "共".$totalPage."?: ";
                $nPage = $nowPage-1;
                $lPage = $nowPage+1;
                if($nowPage==1) $PageList.="上一? ";
                else{
                  if($nPage==1) $PageList.="<a href='view-$aid'>上一?</a> ";
                  else $PageList.="<a href='view-$aid-$nPage.html'>上一?</a> ";
                }
                for($i=1;$i<=$totalPage;$i++)
                {
                        if($i==1){
                          if($nowPage!=1) $PageList.="<a href='view-$aid'>[1]</a> ";
                          else $PageList.="1 ";
                        }else{
                          $n = $i;
                          if($nowPage!=$i) $PageList.="<a href='view-$aid-$i.html'>[".$n."]</a> ";
                          else $PageList.="$n ";
                        }
                }
                if($lPage <= $totalPage) $PageList.="<a href='view-$aid-$lPage.html'>下一?</a> ";
                else $PageList.= "下一? ";
                return $PageList;
        }  

1.2 找到:

        //-------------------------
        //?得???面小??
        //-------------------------
  function GetPageTitlesDM($styleName,$pageNo)
        {
                if($this->TotalPage==1){ return ""; }
                if(count($this->SplitTitles)==0){ return ""; }
                $i=1;
                $aid = $this->ArcID;
                if($styleName=='link')
                {
                        $revalue = "";
                  foreach($this->SplitTitles as $k=>$v){
                           if($i==1) $revalue .= "<a href='view.php?aid=$aid&pageno=$i'>$v</a> ";
                     else{
                              if($pageNo==$i) $revalue .= " $v ";
                              else $revalue .= "<a href='view.php?aid=$aid&pageno=$i'>$v</a> ";
                     }
                     $i++;
                  }
          }else
          {
                  $revalue = "<select id='dedepagetitles' onchange='location.href=this.options[this.selectedIndex].value;'>";
                        foreach($this->SplitTitles as $k=>$v){
                           if($i==1) $revalue .= "<option value='".$this->Fields['phpurl']."/view.php?aid=$aid&pageno=$i'>{$i}、{$v}</option>";
                     else{
                              if($pageNo==$i) $revalue .= "<option value='".$this->Fields['phpurl']."/view.php?aid=$aid&pageno=$i' selected>{$i}、{$v}</option>";
                              else $revalue .= "<option value='".$this->Fields['phpurl']."/view.php?aid=$aid&pageno=$i'>{$i}、{$v}</option>";
                     }
                     $i++;
                  }
                  $revalue .= "</select>";
          }
                return $revalue;
        }

修改?:

  //?取?静??面小??
  function GetPageTitlesDM($styleName,$pageNo)
        {
                if($this->TotalPage==1){ return ""; }
                if(count($this->SplitTitles)==0){ return ""; }
                $i=1;
                $aid = $this->ArcID;
                if($styleName=='link')
                {
                        $revalue = "";
                  foreach($this->SplitTitles as $k=>$v){
                           if($i==1) $revalue .= "<a href='view-$aid-$i.html'>$v</a> ";
                     else{
                              if($pageNo==$i) $revalue .= " $v ";
                              else $revalue .= "<a href='view-$aid-$i.html'>$v</a> ";
                     }
                     $i++;
                  }
          }else
          {
                  $revalue = "<select id='dedepagetitles' onchange='location.href=this.options[this.selectedIndex].value;'>";
                        foreach($this->SplitTitles as $k=>$v){
                           if($i==1) $revalue .= "<option value='".$this->Fields['phpurl']."/view-$aid-$i.html'>{$i}、{$v}</option>";
                     else{
                              if($pageNo==$i) $revalue .= "<option value='".$this->Fields['phpurl']."/view-$aid-$i.html' selected>{$i}、{$v}</option>";
                              else $revalue .= "<option value='".$this->Fields['phpurl']."/view-$aid-$i'>{$i}、{$v}</option>";
                     }
                     $i++;
                  }
                  $revalue .= "</select>";
          }
                return $revalue;
        }  


2、打? /include/inc_channel_unit_functions.php ?找

    return $GLOBALS['cfg_plus_dir']."/view.php?aid=$aid";

改成

    return "/view-$aid.html";//文章??静?

六、完工。把?目和文章都改???,刷新,dedecms全站?静?成功。

把?目和文章批量修改???的SQL?句:

update dede_arctype set isdefault=-1;

update dede_archives set ismake=-1;

 

« 上一篇 | 下一篇 »

Trackbacks

点击获得Trackback地址,Encode: UTF-8

发表评论

评论内容 (必填):