如何从CMS设置我的网页到维护模式?

时间:2010-12-16 23:18:21

标签: php mysql .htaccess content-management-system

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

我的网站看起来像这样:

/ CMS /

的index.php

maintenance.php

如果我将maintenance.php重命名为index.php,CMS仍然有效(我离开了登录区域以便管理员进入)。

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

2 个答案:

答案 0 :(得分: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>

或者,你可以使用和if / else语句在index.php页面中完成所有这些:

</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>

答案 1 :(得分:0)

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