如何修改dedecms根目录的引导页面index.php

如何修改dedecms根目录的引导页面index.php,使域名链接自动跳转到指定的首页面。

操作环境:此操作一般使用在dedecms安装在子目录,而非根目录。

index.php页面代码如下:

<?php
/**
 * @version $Id: index.php 1 9:23 2010-11-11 tianya $
 */
if(!file_exists(dirname(__FILE__).'/data/common.inc.php'))
{
header('Location:install/index.php');
exit();
}
//自动生成HTML版
if(isset($_GET['upcache']) || !file_exists('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 `#@__homepageset`");
 $row['templet'] = MfTemplet($row['templet']);
 $pv = new PartView();
 $pv->SetTemplet($cfg_basedir . $cfg_templets_dir . "/" . $row['templet']);
 $row['showmod'] = isset($row['showmod'])? $row['showmod'] : 0;
 if ($row['showmod'] == 1)
 {
 $pv->SaveToHtml(dirname(__FILE__).'/index.html');
 include(dirname(__FILE__).'/index.html');
 exit();
 } else { 
 $pv->Display();
 exit();
 }
}
else
{
 header('HTTP/1.1 301 Moved Permanently');
 header('Location:index.html');
}
?>


注:file_exists()函数检查文件或者目录是否存在,dirname(__FILE__)当前文件所在目录名。主要是看/data/common.inc.php是否存在。如果不存在就跳转到安装界面。

 

如果修改域名跳转页面为根目录的home文件夹下的index.php页面,需要将以下代码:

 

if(!file_exists(dirname(__FILE__).'/data/common.inc.php'))
{
 header('Location:install/index.php');
 exit();
}

 

修改为:

 

if(file_exists(dirname(__FILE__).'/home/index.php'))
{
 header('Location:home/index.php');
 exit();
}

 

滚动至顶部