【问题标题】:How to set my webpage to maintenance mode from CMS?如何从 CMS 将我的网页设置为维护模式?
【发布时间】:2010-12-16 23:18:21
【问题描述】:

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

我的网站如下所示:

/cms/

index.php

维护.php

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

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

【问题讨论】:

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


    【解决方案1】:

    创建一个打开和关闭维护模式的表单域(数据库中的零或一)。然后您可以在您的 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>
    

    【讨论】:

    • 非常感谢,有时候事情对某人来说如此简单却又如此困难。
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-18
      相关资源
      最近更新 更多