Why is this not working, as in the pre-set 404 page is not loaded:
header("HTTP/1.0 404 Not Found");
exit;
.htaccess
has the ErrorDocument 404 /404.html
directive set.
Thank you.
I unfortunately came across the same issue recently whilst working on a PHP project for work.
Sending a header is essentially only a 'status message', and doesn't make the browser or server show a particular page (although I believe some older versions of IE may show its default 404 page). This means that you will need to create your own 404 error message in your script, as the .htaccess error handling wont work.
My suggestion is to use something along the lines of
header("HTTP/1.0 404 Not Found");
include('./404.html');
exit;
I know it may seem stupid, but so far it's the only way I've found that will work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With