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

首頁 > CMS > 織夢(mèng)DEDE > 正文

織夢(mèng)CMS偽靜態(tài)方法(含偽靜態(tài)規(guī)則)

2024-07-09 22:51:43
字體:
供稿:網(wǎng)友

查看網(wǎng)站空間是否支持偽靜態(tài)?

一般空間都是支持偽靜態(tài)的。Apache服務(wù)器偽靜態(tài)相對(duì)簡(jiǎn)單,直接在.htaccess文件中加入相應(yīng)偽靜態(tài)規(guī)則即可;而IIS服務(wù)器偽靜態(tài)的實(shí)現(xiàn),則需要加載Rewrite組件,然后配置httpd.ini文件。

開啟DedeCms偽靜態(tài)

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

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

c.創(chuàng)建欄目或批量增加欄目時(shí),欄目列表選項(xiàng):選擇“使用動(dòng)態(tài)頁”;添加新文章時(shí),發(fā)布選項(xiàng):選擇“僅動(dòng)態(tài)瀏覽 ”。也可以更改他們的模板,讓他們默認(rèn)就是這兩個(gè)值

d.如果的網(wǎng)站已經(jīng)存在生成的靜態(tài)欄目或文章HTML,那么只需在后臺(tái)-系統(tǒng)-SQL命令行工具中執(zhí)行如下語句:

  1. update dede_arctype set isdefault=-1;
  2. update dede_archives set ismake=-1;

其中,dede是安裝時(shí)的數(shù)據(jù)表前綴,根據(jù)實(shí)際情況替換。

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

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

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

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

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

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

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

a.將GetFileName()中的如下代碼:

//動(dòng)態(tài)文章

  1. if($cfg_rewrite == 'Y')
  2. {
  3. return $GLOBALS["cfg_plus_dir"]."/view-".$aid.'-1.html';

}替換為

//動(dòng)態(tài)文章

  1. if($cfg_rewrite == 'Y')
  2. {
  3. return "/archives/view-".$aid.'-1.html';
  4. }

將文章頁默認(rèn)的/plus/view-1-1.html鏈接格式改為/archives/view-1-1.html,不作更改也行。

b.將GetTypeUrl()中的如下代碼:

//動(dòng)態(tài)

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

//動(dòng)態(tài)

$reurl = "/category/list-".$typeid.".html";這步必須修改,即讓你的頻道或是列表頁URL變更為/category/list-1.html形式。

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

打開/include/arc.listview.class.php,找到獲取動(dòng)態(tài)的分頁列表GetPageListDM()函數(shù)末尾處:

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

$plist = str_replace('plus', 'category', $plist);//將默認(rèn)的plus替換成category

$plist = str_replace('.php?tid=', '-', $plist);將列表分頁默認(rèn)鏈接格式/plus/list-1-2-1.html修改為/category/list-1-2-1.html,這步也可以不作更改。

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

打開/include/arc.archives.class.php,找到獲取動(dòng)態(tài)的分頁列表GetPagebreakDM()函數(shù)末尾片:

$PageList = str_replace(".php?aid=","-",$PageList);替換為

$plist = str_replace('plus', 'archives', $plist);//將默認(rèn)的plus替換成archives

$PageList = str_replace(".php?aid=","-",$PageList);這步不作修改也可以,只是個(gè)人喜好問題。

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

DedeCms默認(rèn)的TAG標(biāo)簽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標(biāo)簽URL中的“.php?”號(hào)就去掉了。

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

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

依次打開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)實(shí)現(xiàn)比較簡(jiǎn)單,只要后臺(tái)開啟偽靜態(tài)支持即可,至于個(gè)別頁面,如ask目錄下的browser.php、question.php以及include目錄下的common.inc.php、functions.inc.php都需要簡(jiǎn)單修改才可以匹配偽靜態(tài)規(guī)則。

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

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

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

1)IIS偽靜態(tài)

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

#首頁偽靜態(tài)規(guī)則,如果不使用動(dòng)態(tài)首頁,請(qǐng)勿必刪除這一行,否則打開首頁會(huì)出現(xiàn)死循環(huán)

  1. RewriteRule ^(.*)/index/.html $1/index/.php [I]

#列表頁偽靜態(tài)規(guī)則

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

#文章頁偽靜態(tài)規(guī)則

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

#搜索偽靜態(tài)規(guī)則

  1. RewriteRule ^(.*)/search/.html(?:(/?.*))* $1/search/.php?$2 [I]

#TAG標(biāo)簽偽靜態(tài)規(guī)則

  1. RewriteRule ^(.*)/tags/.html $1/tags/.php [I]
  2. RewriteRule ^(.*)/tags/(.*)(?:(/?.*))* $1/tags/.php/?//$2 [I]
  3. RewriteRule ^(.*)/tags/(.*)//(?:(/?.*))* $1/tags/.php/?//$2// [I]
  4. RewriteRule ^(.*)/tags/(.*)//([0-9])(?:(/?.*))* $1/tags/.php/?//$2//$3 [I]
  5. RewriteRule ^(.*)/tags/(.*)//([0-9])//(?:(/?.*))* $1/tags/.php/?//$2//$3// [I]

#問答偽靜態(tài)規(guī)則,適用于DedeCmsV5.3-5.6版本,需要修改幾處程序

  1. RewriteRule ^(.*)/post/.html $1/post/.php [I]
  2. RewriteRule ^(.*)/type/.html $1/type/.php [I]
  3. RewriteRule ^(.*)/question-([0-9]+)/.html $1/question/.php/?id=$2 [I]
  4. RewriteRule ^(.*)/browser-1-([0-9]+)/.html $1/browser/.php/?tid=$2 [I]
  5. RewriteRule ^(.*)/browser-2-([0-9]+)/.html $1/browser/.php/?tid2=$2 [I]
  6. RewriteRule ^(.*)/browser-1-([0-9]+)-([0-9]+)/.html $1/browser/.php/?tid=$2&page=$3 [I]
  7. RewriteRule ^(.*)/browser-2-([0-9]+)-([0-9]+)/.html $1/browser/.php/?tid2=$2&page=$3 [I]
  8. RewriteRule ^(.*)/browser-([0-9]+)/.html $1/browser/.php/?lm=$2 [I]
  9. RewriteRule ^(.*)/browser-1-([0-9]+)-([0-9]+)/.html $1/browser/.php/?tid=$2&lm=$3 [I]
  10. RewriteRule ^(.*)/browser-2-([0-9]+)-([0-9]+)/.html $1/browser/.php/?tid2=$2&lm=$3 [I]

2)Apache偽靜態(tài)

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

#提供部分規(guī)則作參考

  1. RewriteRule ^category/list-([0-9]+)/.html$ /plus/list.php?tid=$1
  2. RewriteRule ^category/list-([0-9]+)-([0-9]+)-([0-9]+)/.html$ /plus/list.php?tid=$1&totalresult=$2&PageNo=$3
  3. RewriteRule ^archives/view-([0-9]+)-([0-9]+)/.html$ /plus/view.php?arcID=$1&pageno=$2

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

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

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

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

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 富裕县| 大田县| 阿克陶县| 辛集市| 建阳市| 山东省| 德保县| 会理县| 通渭县| 日土县| 明水县| 登封市| 休宁县| 保康县| 库车县| 繁昌县| 祥云县| 柳林县| 双牌县| 利津县| 安塞县| 天祝| 松潘县| 德江县| 丘北县| 台江县| 乌拉特后旗| 金山区| 成安县| 和政县| 海阳市| 云浮市| 镇雄县| 江川县| 务川| 英德市| 广德县| 宣武区| 赣榆县| 贵定县| 黄浦区|