我正在写我的第一个网页,但我一个问题都解决不了。我正在进行CMS维护设置。我想让选项(下拉)将索引从index.php更改为maintenance.php。
我的网站如下所示:
/cms/
index.php
maintenance.php
如果我将maintenance.php重命名为index.php,内容管理系统仍然可以工作(我离开了登录区,让管理员进入)。
那么,我的问题是:这种最合理的方式是切换到维护模式吗?如果是,那是怎么做的?或者也许有更有效的方法?
发布于 2010-12-17 07:25:03
创建一个用于打开和关闭维护模式的表单域(数据库中的0或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>发布于 2010-12-17 07:26:55
为什么不让“维护模式”符号链接“maintenance.php”到“index.php”呢?当您关闭它时,删除符号链接并使'index.php‘指向'realindex.php’
https://stackoverflow.com/questions/4466315
复制相似问题