dedecms 5.6 完美实现伪静态的方法附打包文件下载

来源:Asp之家 时间:2010-12-08 16:29:00 

dedecms(织梦)完美实现伪静态的方法

测试版本:Dedecms V5.6版本

测试平台:Windows 7

测试环境:IIS 7.5

成功。其他条件下大同小异。

需要的条件:

1、服务器必须支持URL重写。

2、后台开启伪静态。

3、栏目设置使用动态。

4、添加文档时选择使用动态浏览。

5、修改php文件include/channelunit.func.php。

6、修改include/arc.listview.class.php。

7、编写rewrite规则。

操作步骤:

1、加载Rewrite模块(过程略)。

参考:http://hi.baidu.com/elsand/blog/item/96d417264b078a08908f9dcf.html

2、dedecms后台-系统-系统基本参数-核心设置-是否使用伪静态,选“是”。

3、把栏目和文档设置成为动态浏览。可以手动,用sql语句更快。

dedecms后台-SQL命令行工具,执行以下语句

将所有文档设置为“仅动态浏览”:update dede_archives set ismake=-1

将所有栏目设置为“使用动态页”:update dede_arctype set isdefault=-1

改成1就是静态。动态转换为静态后需要重新生成HTML。

添加栏目和文章默认为动态的一劳永逸的方法:

http://hi.baidu.com/elsand/blog/item/cd9fb8be6ae69e0618d81f5f.html

4、修改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";

这个必须修改,是栏目页的。

其实不修改也可以,但是URL地址会长一点。这个是文章的。

5、打开include/arc.listview.class.php

找到

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

(大约在第964行)

在其前面面添加一行

$plist = str_replace('plus/list', 'list', $plist);

这个是列表页分页rewrite的url格式的。

默认是http://www.xxx.com/plus/list-1-2-3.html

现在是http://www.xxx.com/list-1-2-3.html

6、 设置重写规则,在httpd.ini里面写上:

  [ISAPI_Rewrite]
# 缓存3600秒 = 1 小时(hour)
CacheClockRate 3600
RepeatLimit 32
#dedecms Rewrite规则
RewriteRule ^(.*)/index\.html $1/index\.php
RewriteRule ^(.*)/list-([0-9]+)\.html $1/plus/list\.php\?tid=$2
RewriteRule ^(.*)/list-([0-9]+)-([0-9]+)-([0-9]+)\.html $1/plus/list\.php\?tid=$2&TotalResult=$3&PageNo=$4
RewriteRule ^(.*)/view-([0-9]+)-([0-9]+)\.html $1/plus/view\.php\?arcID=$2&pageno=$3

[ISAPI_Rewrite]

# 缓存3600秒 = 1 小时(hour)

CacheClockRate 3600

RepeatLimit 32

#dedecms Rewrite规则

RewriteRule ^(.*)/index\.html $1/index\.php

RewriteRule ^(.*)/list-([0-9]+)\.html $1/plus/list\.php\?tid=$2

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

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


include/channelunit.func.php中
return $GLOBALS["cfg_plus_dir"]."/view-".$aid.'-1.html';
改为 return "/abc/view-".$aid.'-1.html';
return $GLOBALS['cfg_phpurl']."/view.php?aid=$aid";
改为 return "/abc/view.php?aid=$aid";
$reurl = $GLOBALS['cfg_phpurl']."/list.php?tid=".$typeid;
改为 $reurl = "/abc/list-".$typeid.".html";
重写规则改为:
RewriteRule ^(.*)/index\.html $1/index\.php
RewriteRule ^(.*)/abc/list-([0-9]+)\.html $1/plus/list\.php\?tid=$2
RewriteRule ^(.*)/abc/list-([0-9]+)-([0-9]+)-([0-9]+)\.html $1/plus/list\.php\?tid=$2&TotalResult=$3&PageNo=$4
RewriteRule ^(.*)/abc/view-([0-9]+)-([0-9]+)\.html $1/plus/view\.php\?arcID=$2&pageno=$3


4、伪静态可能会出现多个url都是指向相同页面,如果看重SEO效果,则可用robots.txt屏蔽多余url

下载:http://download.jz123.cn/dede56.rar


标签:dedecms,伪静态
0
投稿

猜你喜欢

  • 个人站长打造网站心态之路

    2008-03-24 19:31:00
  • QQ2009 正式版SP6优先体验启动 下载QQ2009正式版SP6

    2009-12-02 11:56:00
  • Windows环境利用虚拟机Vmware安装Mac OS10.11(图文)

    2023-11-03 05:45:28
  • 架设博客服务器要注意什么

    2010-07-07 15:55:00
  • 关于Linux下conda安装caffe与pb转caffe问题

    2023-01-29 19:15:23
  • Linux下的多线程编程(三)

    2022-07-11 05:57:52
  • WindowsIIS6安全保护贴—URL授权全攻略(2)

    2007-09-21 13:55:00
  • 如何做一个赚钱的淘宝客

    2010-05-10 10:44:00
  • 详解Linux多线程使用信号量同步

    2023-11-02 17:12:12
  • 我的西联汇款取款经历

    2009-04-03 12:54:00
  • Exchange 2007 Direct Push Mail功能

    2010-02-25 19:01:00
  • 使用ssh-keygen,实现免密码登陆linux的方法

    2023-03-24 01:56:58
  • 搜索优化外链为王时代 不要忘记内链建设

    2008-12-03 15:39:00
  • CentOS 7系统下安装ftp服务器的全过程

    2023-07-31 06:22:54
  • GoDaddy:如何在Password Vault里编辑密码

    2010-04-24 13:20:00
  • VMware Workstation11.0安装Mac OS X 10.10最完整指南

    2021-11-06 08:07:16
  • Win2000 DNS服务器区域的类型

    2009-01-06 17:28:00
  • Docker容器数据卷介绍及操作示例

    2022-04-03 07:53:30
  • 怎样在xp下安装配置iis[图文教程]

    2008-02-12 16:02:00
  • 保障远程桌面Web连接安全四项注意

    2009-01-21 16:55:00
  • asp之家 网站运营 m.aspxhome.com