2010-12-16 96 views
0

我正在处理我的第一个网页,我无法解决一个问题。我正在进行CMS维护设置。我想做出选择(下拉)将索引从index.php更改为maintenance.php。如何将我的网页设置为CMS的维护模式?

我的网站是这样的:

/CMS/

的index.php

maintenance.php

如果我重新命名maintenance.php到index.php,CMS仍然有效(我离开登录区管理员进入)。

所以,我的问题是:这是最合乎逻辑的方式切换到维护模式?如果是,那么如何?或者也许有更有效的方法?

回答

0

创建一个打开和关闭维护模式(数据库中为零或一个)的表单域。然后,您可以在index.php html标记之前查询该行。如果维护模式行返回1,则将用户转发到maintenance.php页面。

<?php 
// query your database for the maintenance mode boolean 
if($maintenance == '1') header('Location: http://www.example.com/maintenance.php'); 
?> 
<html> 

或者,你可以做到这一切与index.php页面和if/else语句:

</head> 
<body> 
<?php 
    // query your database for the maintenance mode boolean 
    if($maintenance == '1') include('maintenance.php'); 
    else{ 
?> 
<div id="homepage"> 
</div> 
<? } // end else ?> 
</body> 
+0

非常感谢你,有时候有些东西太简单了,但对于某个人来说很难。 – 2010-12-17 01:53:43

0

为什么不把 '维护模式' 符号链接 'maintenance.php' 到'的index.php'?当你关闭它时,删除符号链接并将'index.php'指向'realindex.php'