【发布时间】:2016-02-25 05:19:37
【问题描述】:
我已完成在我的网页上设置维护功能。这是index.php代码
<?php
session_start();
require_once("system/functions.php");
require_once("system/config.php");
if($maintenance == 1){
require_once(header("Location: index.php?page=maintenance"));
die();
session_destroy();
}elseif($maintenance == 0)
{
getPage();
}
?>
我也试过
header("Location: index.php?page=maintenance");
而不是上面的 require once 标头代码。 但是如果我把
require_once("frontend/pages/maintenance.php");
它会起作用的。那么问题是人们可以在地址栏中输入他们想要的每个页面,这会显示出来。我需要它来使用它自己的 url(与上面的 2 个标头代码一起使用,但我收到太多重定向错误),无论如何,您将被重定向到此 url 以查看维护屏幕
maintenance.php文件的php部分:
<?php
if($maintenance == 0){
header("Location: index.php?page=index");
die();
}
else{
header("Location: index.php?page=maintenance");
die();
}
?>
我可以删除maintenance.php文件中的else代码部分,但它总是会重定向到“websitename”/index.php(虽然仍然是维护屏幕,与上面提到的问题相同)
所以我需要更改我的代码,以便在进行维护时,无论如何都会将您重定向到 index.php?page=maintenance。抱歉,如果我错过了一些细节,那就晚了。如果需要,请随时问我这个问题:)
【问题讨论】:
-
实际显示维护页面的代码在哪里?在 index.php 还是在 maintenance.php 中?
-
它在maintenance.php中。现在问题已经解决了:)
标签: php html redirect header maintenance