一、首先必須保證你的空間或服務器支持偽靜態即URL重寫。
二、網站后臺開啟偽靜態。
開啟偽靜態的方法:后臺--》系統--》核心設置,找到:是否使用偽靜態,選擇是,確定保存。
三、網站增加欄目設置使用動態頁。
欄目列表選項: 選擇使用動態頁
四、添加文章時選擇使用動態瀏覽。
發布選項: 選擇 僅動態瀏覽
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.文章詳細頁修改
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";
其實不修改也可以,但是URL地址會長一點,根據自己的需要而設定吧。
六、需要在根目錄下增加一個.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]
#偽靜態文章列表list,文章詳細頁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]
這段代碼實現首頁301跳轉和把index.html跳轉到www域名上,把dede.com改成你的域名即可,如果不需要的話直接刪掉這兩句。簡單的使用下面的代碼:
RewriteEngine On
#偽靜態文章列表list,文章詳細頁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的偽靜態方法,其實也簡單!
更多信息請查看IT技術專欄