相信很多人发现在使用dedecms的时候,如果在浏览器中输入域名打开网站,在网站打开后会自动在域名后面多出一个/index.html,这样看起来不太美观,而且好像对SEO有一点点影响。 看起来域名地址变得长了很多,显得很不美观,也不利于网站优化权重,更会权重分散。
首先告诉大家为什么会出现这个/index.html,原因很简单,那就是你的网站服务器设置的默认首页是index.php而不是index.html,因为当你访问https://你的域名/index.php的时候,你会发现浏览器地址栏马上变成了https://你的域名/index.html。
我们可以通过下面两种方法解决:
第一种:就是前面讲到的在服务器里面或者你购买的虚拟主机的后台将网站的默认首页设置为index.html。
第二种:打开index.php文件,将里面的全部内容替换为下面的代码:
if(isset($_GET['upcache']))
{
require_once (dirname(__FILE__) . "/include/common.inc.php");
require_once DEDEINC."/arc.partview.class.php";
$GLOBALS['_arclistEnv'] = 'index';
$row = $dsql->GetOne("Select * From `dede_homepageset`");
$row['templet'] = MfTemplet($row['templet']);
$pv = new PartView();
$pv->SetTemplet($cfg_basedir . $cfg_templets_dir . "/" . $row['templet']);
$pv->SaveToHtml(dirname(__FILE__).'/index.html');
include(dirname(__FILE__).'/index.html');
exit();
}
else
{
header('HTTP/1.1 301 Moved Permanently');
header('Location:index.html');
}
?>
替换成:
require_once (dirname(__FILE__) . "/include/common.inc.php");
require_once DEDEINC."/arc.partview.class.php";
$GLOBALS['_arclistEnv'] = 'index';
$row = $dsql->GetOne("Select * From `dede_homepageset`");
$row['templet'] = MfTemplet($row['templet']);
$pv = new PartView();
$pv->SetTemplet($cfg_basedir . $cfg_templets_dir . "/" . $row['templet']);
$pv->Display();
?>
替换完成后再通过域名访问你的网站试试,就会发现不会自动出现index.html了。
第三种:将dedecms网站根目录下的index.php改成index.php.bak或者删除掉,生成静态首页。
该文章属于:计算机技术网原创
转载请注明标题:怎么去掉织梦dedecms首页网址后面的index.html-计算机技术网
转载请注明出处:https://www.ctvol.com/seoomethods/2179.html