DEDECMS實(shí)現(xiàn)文章欄目和文章頁面?zhèn)戊o態(tài)方法

字號(hào):


    一、首先必須保證你的空間或服務(wù)器支持偽靜態(tài)即URL重寫。
    二、網(wǎng)站后臺(tái)開啟偽靜態(tài)。
    開啟偽靜態(tài)的方法:后臺(tái)--》系統(tǒng)--》核心設(shè)置,找到:是否使用偽靜態(tài),選擇是,確定保存。
    名單一
    三、網(wǎng)站增加欄目設(shè)置使用動(dòng)態(tài)頁。
    欄目列表選項(xiàng): 選擇使用動(dòng)態(tài)頁
    四、添加文章時(shí)選擇使用動(dòng)態(tài)瀏覽。
    發(fā)布選項(xiàng): 選擇 僅動(dòng)態(tài)瀏覽
    名單二
    return "/view.php?aid=$aid";
    五、dedecms5.7以上版本得改include/helpers/channelunit.helper.php
    dedecms其他版本需要修改php文件include/channelunit.func.php
    名單三
    1.修改欄目頁:
    查找
    function GetTypeUrl
    $reurl = $GLOBALS['cfg_phpurl']."/list.php?tid=".$typeid;
    修改為:
    $reurl = "/list-".$typeid.".html";
    2.文章詳細(xì)頁修改
    1) 查找 function GetFileName 里面的
    return $GLOBALS["cfg_plus_dir"]."/view-".$aid.'-1.html';
    修改為:
    return "/view-".$aid.'-1.html';
    2) 查找
    return $GLOBALS['cfg_phpurl']."/view.php?aid=$aid";
    修改為:
    return "/view.php?aid=$aid";
    其實(shí)不修改也可以,但是URL地址會(huì)長一點(diǎn),根據(jù)自己的需要而設(shè)定吧。
    六、需要在根目錄下增加一個(gè).htaccess文件。
    添加如下代碼:
    Options +FollowSymLinks
    DirectoryIndex index.html
    RewriteEngine On
    RewriteBase /
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /index.(php|html|htm) HTTP/
    RewriteRule ^index.(php|html|htm)$ http://www.dede.com/ [R=301,L]
    #偽靜態(tài)文章列表list,文章詳細(xì)頁view
    RewriteRule ^list-([0-9]+).html$ /plus/list.php?tid=$1
    RewriteRule ^list-([0-9]+)-([0-9]+)-([0-9]+).html$ /plus/list.php?tid=$1&totalresult=$2&PageNo=$3
    RewriteRule ^view-([0-9]+)-1.html$ /plus/view.php?arcID=$1
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /index.(php|html|htm) HTTP/
    RewriteRule ^index.(php|html|htm)$ http://www.dede.com/ [R=301,L]
    這段代碼實(shí)現(xiàn)首頁301跳轉(zhuǎn)和把index.html跳轉(zhuǎn)到www域名上,把dede.com改成你的域名即可,如果不需要的話直接刪掉這兩句。簡單的使用下面的代碼:
    RewriteEngine On
    #偽靜態(tài)文章列表list,文章詳細(xì)頁view
    RewriteRule ^list-([0-9]+).html$ /plus/list.php?tid=$1
    RewriteRule ^list-([0-9]+)-([0-9]+)-([0-9]+).html$ /plus/list.php?tid=$1&totalresult=$2&PageNo=$3
    RewriteRule ^view-([0-9]+)-1.html$ /plus/view.php?arcID=$1
    以上就完成了dedecms的偽靜態(tài)方法,其實(shí)也簡單!