DEDECMS系统栏目、文章页面、分页面伪静态和域名301重定向详细方法:
1、服务器必须支持URL重写。
2、后台开启伪静态。
3、栏目设置使用动态。
4。添加文档时选择使用动态浏览。
5。需要修改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"; 其实不修改也可以,但是URL地址会长一点。这个是文章的。
查找
$reurl = $GLOBALS['cfg_phpurl']."/list.php?tid=".$typeid; 修改为
$reurl = "/list-".$typeid.".html"; 这个必须修改,是栏目页的。
6、需要在根目录下增加一个.htaccess文件(只适用于linux系统,并需要虚拟主机支持)。
添加如下:
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{http_host} ^xianjianhot.com [NC] RewriteRule ^(.*)$ http://www.xianjianhot.com/$1 [L,R=301] 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 RewriteRule ^view-([0-9]+)-([0-9]+)\.html$ /plus/view.php?aid=$1&pageno=$2 </IfModule> 说明: 1、
RewriteCond %{http_host} ^
xianjianhot.com [NC]
RewriteRule ^(.*)$
http://www.xianjianhot.com/$1 [L,R=301]
此为域名301重定向指令,放在其它重写命令前面。其中域名替换成自己网站域名。这有利于网站的SEO。如果不看重则可以不要。
2、
RewriteRule ^view-([0-9]+)-([0-9]+)\.html$ /plus/view.php?aid=$1&pageno=$2
此为文章分页重写命令。如果view替换成自己设置的其他词,则需要把
include/arc.archives.class.php文件中的view同时替换掉。
伪静态后效果请看
http://www.xianjianhot.com/ 和
http://www.xianjianhot.com/xianjian-113-1.html (文章分页效果)
3、
伪静态可能会出现多个url都是指向相同页面,如果看重SEO效果,则可用robots.txt屏蔽多余url。
文章是根据论坛前辈们的伪静态方法实践总结而来。在此感谢论坛各位前辈。文章中方法有不足之处请多指点.^_^
[ 此帖被abldown在2009-02-15 11:00重新编辑 ]