国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > CMS > 織夢DEDE > 正文

最詳細的織夢Dedecms偽靜態(tài)方法(含偽靜態(tài)規(guī)則)

2024-07-12 08:55:10
字體:
來源:轉載
供稿:網友

1)你的網站空間是否支持偽靜態(tài)?

這點很重要,不然一切都是白搭。你可以與空間的IDC商聯(lián)系一下,如果是自己的服務器,那就更好辦了,一般來說,空間都是支持偽靜態(tài)的。Apache服務器偽靜態(tài)相對簡單,直接在.htaccess文件中加入相應偽靜態(tài)規(guī)則即可;而IIS服務器偽靜態(tài)的實現(xiàn),則需要加載Rewrite組件,然后配置httpd.ini文件。

2)開啟DedeCms偽靜態(tài)

a.后臺-系統(tǒng)參數(shù)-核心設置-是否使用偽靜態(tài):選擇“是”;

b.如果你啟用了問答模塊,則后臺-系統(tǒng)參數(shù)-模塊設置-是否使用偽靜態(tài):選擇“是”;

c.創(chuàng)建欄目或批量增加欄目時,欄目列表選項:選擇“使用動態(tài)頁”;添加新文章時,發(fā)布選項:選擇“僅動態(tài)瀏覽 ”。當然,你也可以更改他們的模板,讓他們默認就是這兩個值,一勞永逸。修改方法很簡單,稍懂些HTML基礎就行了,這里就不再累述了。

d.如果你的網站已經存在生成的靜態(tài)欄目或文章HTML,那么只需在后臺-系統(tǒng)-SQL命令行工具中執(zhí)行如下語句:
update dede_arctype set isdefault=-1;
update dede_archives set ismake=-1;
其中,dede是你安裝時的數(shù)據(jù)表前綴,根據(jù)實際情況替換。

事實上,開啟DedeCms偽靜態(tài)支持并不能完全在后臺配置,有很多地方還是需要手動修改的,期望官方完善。

織夢DedeCms偽靜態(tài)方法

織夢DedeCms偽靜態(tài),涉及到PHP源碼的修改,你可以借助Dreamweaver或是EditPlus一類編輯軟件來操作。下面說下織夢DedeCms全站偽靜態(tài)的實現(xiàn)方法,適用于V5.3以上版本。小拼的DedeCms偽靜態(tài)測試環(huán)境是Windows IIS6,舉一反三,Linux或其它服務器的偽靜態(tài)實現(xiàn)原理都是一樣的,只要搞清楚思路就行了。

1)DedeCms首頁偽靜態(tài)

把站點根目錄下index.html刪除,以后不更新主頁HTML即可,當然你也可以選擇不使用動態(tài)首頁。

2)DedeCms頻道|列表頁|文章頁偽靜態(tài)

主要通過修改GetFileName()、GetTypeUrl()這兩個函數(shù)實現(xiàn)。DedeCms V5.3、DedeCms V5.7和DedeCms V5.6版本,打開/include/channelunit.func.php進行修改。注意:DedeCms V5.7,此文件路徑更改了,你打開/include/helpers/channelunit.helper.php即可。

a.將GetFileName()中的如下代碼:
//動態(tài)文章
if($cfg_rewrite == 'Y')
{
return $GLOBALS["cfg_plus_dir"]."/view-".$aid.'-1.html';
}替換為
//動態(tài)文章
if($cfg_rewrite == 'Y')
{
return "/archives/view-".$aid.'-1.html';
}將文章頁默認的/plus/view-1-1.html鏈接格式改為/archives/view-1-1.html,這個隨個人喜歡,不作更改也行。

b.將GetTypeUrl()中的如下代碼:
//動態(tài)
$reurl = $GLOBALS['cfg_phpurl']."/list.php?tid=".$typeid;替換為
//動態(tài)
$reurl = "/category/list-".$typeid.".html";這步必須修改,即讓你的頻道或是列表頁URL變更為/category/list-1.html形式。

3)DedeCms列表分頁偽靜態(tài)

打開/include/arc.listview.class.php,找到獲取動態(tài)的分頁列表GetPageListDM()函數(shù)末尾處:
$plist = str_replace('.php?tid=', '-', $plist);替換為
$plist = str_replace('plus', 'category', $plist);//將默認的plus替換成category
$plist = str_replace('.php?tid=', '-', $plist);將列表分頁默認鏈接格式/plus/list-1-2-1.html修改為/category/list-1-2-1.html,這步也可以不作更改。

4)DedeCms文章分頁偽靜態(tài)

打開/include/arc.archives.class.php,找到獲取動態(tài)的分頁列表GetPagebreakDM()函數(shù)末尾片:
$PageList = str_replace(".php?aid=","-",$PageList);替換為
$plist = str_replace('plus', 'archives', $plist);//將默認的plus替換成archives
$PageList = str_replace(".php?aid=","-",$PageList);這步不作修改也可以,只是個人喜好問題。

5)DedeCmsTAG標簽偽靜態(tài)

DedeCms默認的TAG標簽URL,形如/tags.php?/dedecms5.7/,非常之難看。打開/include/taglib/tag.lib.php,找到lib_tag()函數(shù)下的:
$row['link'] = $cfg_cmsurl."/tags.php?/".urlencode($row['keyword'])."/";替換為
$row['link'] = $cfg_cmsurl."/tags/".urlencode($row['keyword'])."/";到這里,TAG標簽URL中的“.php?”號就去掉了。

6)DedeCms搜索偽靜態(tài)

DedeCms搜索URL靜態(tài)化比較麻煩,附帶參數(shù)多不說,參數(shù)也可能變化,像搜索結果分頁的URL就特麻煩,偽靜態(tài)規(guī)則匹配復雜。就偷下懶,將搜索URL中“search.php?…”直接替換為“search.html?…”,至于“?”號之后的參數(shù)以任意字符進行匹配。

依次打開include文件夾下的channelunit.func.php、arc.searchview.class.php、arc.taglist.class.php以及/include/taglib/hotwords.lib.php,查找“search.php?”替換為“search.html?”即可。

7)DedeCms問答偽靜態(tài)

問答模塊的偽靜態(tài)實現(xiàn)比較簡單,只要后臺開啟偽靜態(tài)支持即可,至于個別頁面,如ask目錄下的browser.php、question.php以及include目錄下的common.inc.php、functions.inc.php都需要簡單修改才可以匹配偽靜態(tài)規(guī)則。

注意一點,DedeCms V5.7問答模塊整體升級了,之前的規(guī)則已經不適用了,小拼以后會專門寫個教程供大家參考的。

DedeCms偽靜態(tài)規(guī)則

依照上面的步驟修改完畢,接下來配置好你的偽靜態(tài)規(guī)則,DedeCms全站偽靜態(tài)就完美實現(xiàn)了。

1)IIS偽靜態(tài)

打開httpd.ini文件,加入如下規(guī)則:

#首頁偽靜態(tài)規(guī)則,如果不使用動態(tài)首頁,請勿必刪除這一行,否則打開首頁會出現(xiàn)死循環(huán)
RewriteRule ^(.*)/index/.html $1/index/.php [I]
#列表頁偽靜態(tài)規(guī)則
RewriteRule ^(.*)/category/list-([0-9]+)/.html $1/plus/list/.php/?tid=$2 [I]
RewriteRule ^(.*)/category/list-([0-9]+)-([0-9]+)-([0-9]+)/.html $1/plus/list/.php/?tid=$2&TotalResult=$3&PageNo=$4 [I]
#文章頁偽靜態(tài)規(guī)則
RewriteRule ^(.*)/archives/view-([0-9]+)-([0-9]+)/.html $1/plus/view/.php/?arcID=$2&pageno=$3 [I]
#搜索偽靜態(tài)規(guī)則
RewriteRule ^(.*)/search/.html(?:(/?.*))* $1/search/.php?$2 [I]
#TAG標簽偽靜態(tài)規(guī)則
RewriteRule ^(.*)/tags/.html $1/tags/.php [I]
RewriteRule ^(.*)/tags/(.*)(?:(/?.*))* $1/tags/.php/?//$2 [I]
RewriteRule ^(.*)/tags/(.*)//(?:(/?.*))* $1/tags/.php/?//$2// [I]
RewriteRule ^(.*)/tags/(.*)//([0-9])(?:(/?.*))* $1/tags/.php/?//$2//$3 [I]
RewriteRule ^(.*)/tags/(.*)//([0-9])//(?:(/?.*))* $1/tags/.php/?//$2//$3// [I]
#問答偽靜態(tài)規(guī)則,適用于DedeCmsV5.3-5.6版本,需要修改幾處程序
RewriteRule ^(.*)/post/.html $1/post/.php [I]
RewriteRule ^(.*)/type/.html $1/type/.php [I]
RewriteRule ^(.*)/question-([0-9]+)/.html $1/question/.php/?id=$2 [I]
RewriteRule ^(.*)/browser-1-([0-9]+)/.html $1/browser/.php/?tid=$2 [I]
RewriteRule ^(.*)/browser-2-([0-9]+)/.html $1/browser/.php/?tid2=$2 [I]
RewriteRule ^(.*)/browser-1-([0-9]+)-([0-9]+)/.html $1/browser/.php/?tid=$2&page=$3 [I]
RewriteRule ^(.*)/browser-2-([0-9]+)-([0-9]+)/.html $1/browser/.php/?tid2=$2&page=$3 [I]
RewriteRule ^(.*)/browser-([0-9]+)/.html $1/browser/.php/?lm=$2 [I]
RewriteRule ^(.*)/browser-1-([0-9]+)-([0-9]+)/.html $1/browser/.php/?tid=$2&lm=$3 [I]
RewriteRule ^(.*)/browser-2-([0-9]+)-([0-9]+)/.html $1/browser/.php/?tid2=$2&lm=$3 [I]

2)Apache偽靜態(tài)

打開.htaccess文件,加入如下規(guī)則:

#提供部分規(guī)則作參考
RewriteRule ^category/list-([0-9]+)/.html$ /plus/list.php?tid=$1
RewriteRule ^category/list-([0-9]+)-([0-9]+)-([0-9]+)/.html$ /plus/list.php?tid=$1&totalresult=$2&PageNo=$3
RewriteRule ^archives/view-([0-9]+)-([0-9]+)/.html$ /plus/view.php?arcID=$1&pageno=$2

DedeCms偽靜態(tài)注意事項

1)以上提供的DedeCms偽靜態(tài)修改以及規(guī)則都是按照個人的修改步驟來的,僅供參考,你可以根據(jù)站點的實際情況作相應調整;

2)偽靜態(tài)實現(xiàn)思路,即根據(jù)理想的URL結構寫好偽靜態(tài)規(guī)則,然后對程序進行相應修改,并沒有你想象中的那么復雜;

3)不會程序、不會正則都沒有關系,但是思路一定要清晰,還有就是禁得住“折騰”,多研究,搞透了,對提升自己也有極大好處。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 隆德县| 阳曲县| 衢州市| 正蓝旗| 民乐县| 尉犁县| 上饶市| 琼结县| 扎鲁特旗| 苍南县| 瑞丽市| 广宗县| 葫芦岛市| 上饶县| 睢宁县| 长泰县| 海门市| 乌审旗| 马边| 余庆县| 宁陵县| 山西省| 永济市| 柘荣县| 同德县| 蓬莱市| 华宁县| 察哈| 辽宁省| 宁武县| 太仓市| 桐城市| 建阳市| 朔州市| 普陀区| 盱眙县| 普宁市| 章丘市| 临漳县| 满洲里市| 昂仁县|