dedecms 5.6 完美實(shí)現(xiàn)偽靜態(tài)的方法附打包文件下載
來(lái)源:易賢網(wǎng) 閱讀:934 次 日期:2016-07-01 10:45:18
溫馨提示:易賢網(wǎng)小編為您整理了“dedecms 5.6 完美實(shí)現(xiàn)偽靜態(tài)的方法附打包文件下載”,方便廣大網(wǎng)友查閱!

dedecms(織夢(mèng))完美實(shí)現(xiàn)偽靜態(tài)的方法

測(cè)試版本:Dedecms V5.6版本

測(cè)試平臺(tái):Windows 7

測(cè)試環(huán)境:IIS 7.5

成功。其他條件下大同小異。

需要的條件:

1、服務(wù)器必須支持URL重寫(xiě)。

2、后臺(tái)開(kāi)啟偽靜態(tài)。

3、欄目設(shè)置使用動(dòng)態(tài)。

4、添加文檔時(shí)選擇使用動(dòng)態(tài)瀏覽。

5、修改php文件include/channelunit.func.php。

6、修改include/arc.listview.class.php。

7、編寫(xiě)rewrite規(guī)則。

操作步驟:

1、加載Rewrite模塊(過(guò)程略)。

參考:http://hi.baidu.com/elsand/blog/item/96d417264b078a08908f9dcf.html

2、dedecms后臺(tái)-系統(tǒng)-系統(tǒng)基本參數(shù)-核心設(shè)置-是否使用偽靜態(tài),選“是”。

3、把欄目和文檔設(shè)置成為動(dòng)態(tài)瀏覽??梢允謩?dòng),用sql語(yǔ)句更快。

dedecms后臺(tái)-SQL命令行工具,執(zhí)行以下語(yǔ)句

將所有文檔設(shè)置為“僅動(dòng)態(tài)瀏覽”:update dede_archives set ismake=-1

將所有欄目設(shè)置為“使用動(dòng)態(tài)頁(yè)”:update dede_arctype set isdefault=-1

改成1就是靜態(tài)。動(dòng)態(tài)轉(zhuǎn)換為靜態(tài)后需要重新生成HTML。

添加欄目和文章默認(rèn)為動(dòng)態(tài)的一勞永逸的方法:

http://hi.baidu.com/elsand/blog/item/cd9fb8be6ae69e0618d81f5f.html

4、修改php文件include/channelunit.func.php

查找

return $GLOBALS["cfg_plus_dir"]."/view-".$aid.'-1.html';

修改為

return "/view-".$aid.'-1.html';

查找

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

修改為

return "/view.php?aid=$aid";

其實(shí)頁(yè)可以不修改,就是URL地址會(huì)長(zhǎng)一點(diǎn)。這個(gè)是文章頁(yè)的。

查找

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

修改為

$reurl = "/list-".$typeid.".html";

這個(gè)必須修改,是欄目頁(yè)的。

其實(shí)不修改也可以,但是URL地址會(huì)長(zhǎng)一點(diǎn)。這個(gè)是文章的。

5、打開(kāi)include/arc.listview.class.php

找到

$plist = str_replace('.php?tid=', '-', $plist);

(大約在第964行)

在其前面面添加一行

$plist = str_replace('plus/list', 'list', $plist);

這個(gè)是列表頁(yè)分頁(yè)rewrite的url格式的。

默認(rèn)是http://www.xxx.com/plus/list-1-2-3.html

現(xiàn)在是http://www.xxx.com/list-1-2-3.html

6、 設(shè)置重寫(xiě)規(guī)則,在httpd.ini里面寫(xiě)上:

[ISAPI_Rewrite]

# 緩存3600秒 = 1 小時(shí)(hour)

CacheClockRate 3600

RepeatLimit 32

#dedecms Rewrite規(guī)則

RewriteRule ^(.*)/index\.html $1/index\.php

RewriteRule ^(.*)/list-([0-9]+)\.html $1/plus/list\.php\?tid=$2

RewriteRule ^(.*)/list-([0-9]+)-([0-9]+)-([0-9]+)\.html $1/plus/list\.php\?tid=$2&TotalResult=$3&PageNo=$4

RewriteRule ^(.*)/view-([0-9]+)-([0-9]+)\.html $1/plus/view\.php\?arcID=$2&pageno=$3

7、如果不使用動(dòng)態(tài)首頁(yè)

把rewrite規(guī)則中的

RewriteRule ^(.*)/index\.html $1/index\.php

去掉,或改為

RewriteRule ^(.*)/index\.html $1/index\.html

否則打開(kāi)http://www.xxx.com/index.html時(shí)會(huì)陷入死循環(huán)。

說(shuō)明:

1、RewriteRule ^view-([0-9]+)-([0-9]+)\.html$ /plus/view.php?aid=$1&pageno=$2

此為文章分頁(yè)重寫(xiě)命令。

2、如果view替換成自己設(shè)置的其他詞,則需要把include/arc.archives.class.php文件中的view同時(shí)替換掉。

3、重寫(xiě)后的URL如下:

文章頁(yè):http://www.xxx.com/view-1-1.html

列表頁(yè):http://www.xxx.com/list-1.html

如果需要改成如下格式:

文章頁(yè):http://www.xxx.com/abc/view-1-1.html

列表頁(yè):http://www.xxx.com/abc/list-1.html

include/channelunit.func.php中

return $GLOBALS["cfg_plus_dir"]."/view-".$aid.'-1.html';

改為 return "/abc/view-".$aid.'-1.html';

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

改為 return "/abc/view.php?aid=$aid";

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

改為 $reurl = "/abc/list-".$typeid.".html";

重寫(xiě)規(guī)則改為:

RewriteRule ^(.*)/index\.html $1/index\.php

RewriteRule ^(.*)/abc/list-([0-9]+)\.html $1/plus/list\.php\?tid=$2

RewriteRule ^(.*)/abc/list-([0-9]+)-([0-9]+)-([0-9]+)\.html $1/plus/list\.php\?tid=$2&TotalResult=$3&PageNo=$4

RewriteRule ^(.*)/abc/view-([0-9]+)-([0-9]+)\.html $1/plus/view\.php\?arcID=$2&pageno=$3

4、偽靜態(tài)可能會(huì)出現(xiàn)多個(gè)url都是指向相同頁(yè)面,如果看重SEO效果,則可用robots.txt屏蔽多余url。

/201009/yuanma/dede56.rar

更多信息請(qǐng)查看CMS教程
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢(xún)回復(fù)僅供參考,敬請(qǐng)考生以權(quán)威部門(mén)公布的正式信息和咨詢(xún)?yōu)闇?zhǔn)!
相關(guān)閱讀CMS教程
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡(jiǎn)要咨詢(xún) | 簡(jiǎn)要咨詢(xún)須知 | 加入群交流 | 手機(jī)站點(diǎn) | 投訴建議
工業(yè)和信息化部備案號(hào):滇ICP備2023014141號(hào)-1 云南省教育廳備案號(hào):云教ICP備0901021 滇公網(wǎng)安備53010202001879號(hào) 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號(hào)
云南網(wǎng)警備案專(zhuān)用圖標(biāo)
聯(lián)系電話(huà):0871-65317125(9:00—18:00) 獲取招聘考試信息及咨詢(xún)關(guān)注公眾號(hào):hfpxwx
咨詢(xún)QQ:526150442(9:00—18:00)版權(quán)所有:易賢網(wǎng)
云南網(wǎng)警報(bào)警專(zhuān)用圖標(biāo)