DEDECMS实现文章栏目和文章页面伪静态方法
文章首发光年论坛.
DEDECMS实现文章栏目和文章页面伪静态方法:
一、首先必须保证你的空间或服务器支持伪静态即URL重写。
二、网站后台开启伪静态。
开启伪静态的方法:后台–》系统–》核心设置
找到:是否使用伪静态: 选择是 确定保存。

三、网站增加栏目设置使用动态页。
栏目列表选项: 选择使用动态页

四、添加文章时选择使用动态浏览。
发布选项: 选择 仅动态浏览

五、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的伪静态方法,其实也简单,如果有需要 不懂的可以PM我。
现在研究首页实现定时刷新,研究出来再分享给大家。