I'm trying to return the default 404 error page in IIS-8. I'm using this code:
// Return 404 in case no product was found
if($product_index == -1) {
header('HTTP/1.0 404 Not Found');
exit;
}
This code responds with a 404-error, but the page is just blank.
Is there a way to include the default 404 error page using PHP?
Simply add header again for redirecting to 404 page like below:
// 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;
}
If you still get trouble due to IIS-8, then you can follow Custom 404 error page not working on IIS 8.5
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.