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

发布于 2024-10-08 04:50:02 字数 287 浏览 0 评论 0原文

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

我的网站如下所示:

/cms/index.phpmaintenance.php

重命名为index.php

如果我将maintenance.php

,CMS仍然可以工作(我留下了登录区域供管理员进入)。

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

I'm working on my first web page and I can't solve one problem. I'm making CMS maintenance settings. I want to make option (drop down) to change index from index.php to maintenance.php.

My site looks like this:

/cms/

index.php

maintenance.php

If I rename maintenance.php to index.php, CMS still works (I left log in area for admin to get in).

So, my question: is this most logical way switch to maintenance mode? If yes, then how? Or maybe there is more efficient way?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月下凄凉 2024-10-15 04:50:02

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

Create a form field that toggles maintenance mode on and off (a zero or a one in the database). Then you can query that row before your your index.php html tag. if the maintenance mode row returns a 1, forward the user to the maintenance.php page.

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

Alternatively, you could do all of this in the index.php page with and if/else statement:

</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>
老街孤人 2024-10-15 04:50:02

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

Why not make 'maintenance mode' symlink 'maintenance.php' to 'index.php'? When you turn it off, delete the symlink and make 'index.php' point to 'realindex.php'

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文