我正在尝试在IIS-8中返回默认的404错误页。我使用的是以下代码:
// Return 404 in case no product was found
if($product_index == -1) {
header('HTTP/1.0 404 Not Found');
exit;
}这段代码返回404-错误,但是页面是空白的。
有没有办法使用PHP包含默认的404错误页面?
发布于 2017-12-03 16:02:19
只需再次添加标题,重定向到404页面,如下所示:
// Return 404 in case no product was found
if($product_index == -1) {
header('HTTP/1.0 404 Not Found');
header("Location: http://yoursite/404.php");
exit;
}如果您仍然因为IIS-8而遇到麻烦,那么您可以使用Custom 404 error page not working on IIS 8.5
https://stackoverflow.com/questions/33200504
复制相似问题