我刚刚完成了网页维护功能的安装。以下是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以查看维护屏幕。
维护.php文件的php部分:
<?php
if($maintenance == 0){
header("Location: index.php?page=index");
die();
}
else{
header("Location: index.php?page=maintenance");
die();
}
?>
我可以在maintenance.php文件中删除else代码部分,但这样它将始终重定向到“网站名称”/index.php(尽管仍然是维护屏幕,与上述相同的问题)
所以当有维护时,我需要更改我的代码,无论如何都会重定向到index.php?page=maintenance。如果我漏掉了一些细节,很抱歉,现在已经很晚了。如果需要的话,请随时问我:)