您的位置:首页 > Web前端 > HTML

DEDECMS首页自动生成静态文件index.html

2017-01-09 14:45 489 查看
织梦没有自动生成静态首页文件index.html ,这样如果不小心删除了index.html而又没有在后台生成,那么访问网站,则会出现首页404错误。
<?php
if(!file_exists(dirname(__FILE__).'/data/common.inc.php')) {
header('Location:install/index.php'); exit();
} //自动生成HTML版,加上
//!file_exists(dirname(__FILE__).'/index.html'),如果不存在index.html,则自动生成index.html
if(isset($_GET['upcache']) || !file_exists(dirname(__FILE__).'/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->SaveToHtml(dirname(__FILE__).'/index.html');
include(dirname(__FILE__).'/index.html');
exit();
} else {
header('HTTP/1.1 301 Moved Permanently');
header('Location:index.html');
}
?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息