织梦dedecms去掉网站首页链接后边的index.html

有时候织梦dedecms网站默认生成首页后,首页的链接后面会多出一个index.html,这个index.html怎么看都不舒服,而且也不利于seo中主页url的统一,所以出于不让首页权重分散考虑,同时也是美观考虑,织梦dedecms网站首页的index.html还是得去掉好,解决首页域名跳转到/index.html问题。

织梦dedecms首页去掉index.html的几种方法:文章源自SEO视频网-https://www.seoshipin.cn/jianzhan/dedecms/2201.html

1、在空间面板里面找到默认首页设置文章源自SEO视频网-https://www.seoshipin.cn/jianzhan/dedecms/2201.html

把index.html提到最前面文章源自SEO视频网-https://www.seoshipin.cn/jianzhan/dedecms/2201.html

2、修改网站根目录下的index.php文件文章源自SEO视频网-https://www.seoshipin.cn/jianzhan/dedecms/2201.html

如果你在服务器上已经设置了默认文档,依然显示index.html的话,可以用下面的方法解决:文章源自SEO视频网-https://www.seoshipin.cn/jianzhan/dedecms/2201.html

找到网站根目录下的index.php文件文章源自SEO视频网-https://www.seoshipin.cn/jianzhan/dedecms/2201.html

  1. header('HTTP/1.1 301 Moved Permanently');
  2. header('Location:index.html');

把上面这两行换成:文章源自SEO视频网-https://www.seoshipin.cn/jianzhan/dedecms/2201.html

  1. include(dirname(__FILE__).'/index.html');
  2. exit();

注:还不成功,一般是因为浏览器没有清空缓存。文章源自SEO视频网-https://www.seoshipin.cn/jianzhan/dedecms/2201.html

3.使用.htaccess文件文章源自SEO视频网-https://www.seoshipin.cn/jianzhan/dedecms/2201.html

目前使用的是这个办法,试验成功。文章源自SEO视频网-https://www.seoshipin.cn/jianzhan/dedecms/2201.html

方法如下:

在根目录的.htaccess里加入以下代码:

  1. DirectoryIndex index.html index.php index.htm

就这么简单。

4、按官方给的更新说明 替换index.php的内容 生成动态,

如果首页不需要生成HTML的, 把index.php换成下面代码,当然如果要生成html就不行了。

  1. <?php
  2. if(!file_exists(dirname(__FILE__).'/data/common.inc.php'))
  3. {
  4. header('Location:install/index.php');
  5. exit();
  6. }
  7. require_once (dirname(__FILE__) . "/include/common.inc.php");
  8. require_once DEDEINC."/arc.partview.class.php";
  9. $GLOBALS['_arclistEnv'] = 'index';
  10. $row = $dsql->GetOne("Select * From `dede_homepageset`");
  11. $row['templet'] = MfTemplet($row['templet']);
  12. $pv = new PartView();
  13. $pv->SetTemplet($cfg_basedir . $cfg_templets_dir . "/" . $row['templet']);
  14. $pv->Display();
  15. ?>
 
  • 本文由 潮涌SEO 发表于 2018年3月9日 14:11:58
  • 转载请务必保留本文链接:https://www.seoshipin.cn/jianzhan/dedecms/2201.html