Hi Guys,
Is there a way to force a 404 error to the browser? I have tried the following with no success:
header('HTTP/1.0 404 not found');
Hi Guys,
Is there a way to force a 404 error to the browser? I have tried the following with no success:
header('HTTP/1.0 404 not found');
that will work. get httpfox for firefox and you can check the return codes.
Ok, but it’s not forcing a redirect to the 404 page, any ideas?
still struggling with this? would greatly appreciate any help…
All it does its return the status code, it doesn’t force a redirect to any 404 page or anything. You have to do that yourself.
How would I redirect to 404.shtml?
Best way is probably just to include() it after sending the status code, then exit().
try
ErrorDocument 404 /notfound.html
in .htaccess
That will work for apache generated 404 errors. For ones you throw in php, you will need to output the page yourself.
The easiest way would be:
header(“Location: dkjlflkjxfgkdnbcxfn.html”);
As long as you don’t actually have a page with that filename.
Then there is little point in outputting the 404 header, since that would generate the error anyway. Would look a bit rubbish though.
Did you try
header("HTTP/1.0 404 Not Found");
echo "<h1>404 File not found</h1>";
?
er… ignore me… I’m half reading… half working >.>
you can also try
header("Status: 404 Not Found");
echo "<h1>404 File not found</h1>";