【发布时间】:2016-11-17 23:46:33
【问题描述】:
我在下面有处理 404 错误的代码,但我喜欢将所有 404 错误重定向到主页,这就是我所拥有的:
function show_404($page = '', $log_error = TRUE)
{
$heading = "404 Page Not Found";
$message = "The page you requested was not found.";
// By default we log this, but allow a dev to skip it
if ($log_error)
{
log_message('error', '404 Page Not Found --> '.$page);
}
echo $this->show_error($heading, $message, 'error_404', 404);
exit;
}
我怎样才能重定向到主页而不是给出 404 错误。
【问题讨论】:
-
重定向到首页,然后显示实际错误?
-
header("location: index.php"),您想知道如何重定向吗? -
Php header redirect的可能重复
-
上面的代码是我目前的,我只是想重定向到主页,仅此而已。
-
@user2969009,正如 Sam 所说的
header("location: index.php")。你试过了吗?
标签: php redirect http-status-code-404