当前位置:首页 > CMS教程 > DeDecms > 列表

如何去掉DEDE首页index.html

发布:smiling 来源: PHP粉丝网  添加日期:2015-03-17 16:18:59 浏览: 评论:0 

dede织梦系统按照默认的设置安装后,访问首页时候,域名后面总跟随着一个/index.html的后缀,从SEO方面来说,这样很不好,比如你的连接都是www.phpfensi.com,而访问这个域名时候,实际上打开的页面总是www.phpfensi.com/index.html,这样你的网站权重就分散了。

DEDE如何去掉首页index.html?这样做有什么用,为什么要去掉啊?

答案就是这样做的效果就是域名url做的更短,这样对我们网站的优化是非常有好处的,那么我们该怎么做呢?

首先,我想强调的一点就是有的空间可能默认显示的就是没带index.html,那么下面的内容你可以忽略掉了。

我们有两种方法可以实现:

第一种:就是在你的空间控制面板中,将index.html默认首页的优先级设为最高。一般的空间都会提供这种功能,这也是最好的,如果万一,不能怎么办呢?别慌有下面的一种方法即可:

第二种:我们找到dede根目录下的index.php文件,在www/ dede自带的index.php,原代码:

  1. if(!file_exists(dirname(__FILE__).'/data/common.inc.php')) 
  2. { 
  3. header('Location:install/index.php'); 
  4. exit(); 
  5. } 
  6. //自动生成HTML版 
  7. if(isset($_GET['upcache'])) 
  8. { 
  9. require_once (dirname(__FILE__) . "/include/common.inc.php"); 
  10. require_once DEDEINC."/arc.partview.class.php"; 
  11. $GLOBALS['_arclistEnv'] = 'index'; 
  12. $row = $dsql->GetOne("Select * From `dede_homepageset`"); 
  13. $row['templet'] = MfTemplet($row['templet']); 
  14. $pv = new PartView(); 
  15. $pv->SetTemplet($cfg_basedir . $cfg_templets_dir . "/" . $row['templet']); 
  16. $pv->SaveToHtml(dirname(__FILE__).'/index.html'); 
  17. include(dirname(__FILE__).'/index.html'); 
  18. exit(); 
  19. } 
  20. else 
  21. { 
  22. header('HTTP/1.1 301 Moved Permanently'); 
  23. header('Location:index.html'); 
  24. } 
  25. ?> 
  26. //替换为 
  27. if(!file_exists(dirname(__FILE__).'/data/common.inc.php')) 
  28. { 
  29. header('Location:install/index.php'); 
  30. exit(); //phpfensi.com 
  31. } 
  32. require_once (dirname(__FILE__) . "/include/common.inc.php"); 
  33. require_once DEDEINC."/arc.partview.class.php"; 
  34. $GLOBALS['_arclistEnv'] = 'index'; 
  35. $row = $dsql->GetOne("Select * From `dede_homepageset`"); 
  36. $row['templet'] = MfTemplet($row['templet']); 
  37. $pv = new PartView(); 
  38. $pv->SetTemplet($cfg_basedir . $cfg_templets_dir . "/" . $row['templet']); 
  39. $pv->Display(); 
  40. ?> 

试试吧,是不是已经搞定了!

Tags: DEDE首页 去掉index html

分享到: