![]() |
Return 404 on mistyped url variables
I've been trying to figure out PHP and 404 errors.
If somebody types Code:
http://site.com/?id=validIf they type Code:
http://site.com/?id=invalidI tried: Code:
header("HTTP/1.0 404 Not Found");Code:
HTTP/1.1 200 OKHow can properly I deliver a 404? Thanks a lot |
Re: the issue of not getting a 404:
Here's what I use: PHP Code:
Also you must ensure that nothing gets sent to the browser before the header() call. Look for echo() and print() before the header() calls. As to sending the user to a good page after a few seconds, I don't think that's possible with a real 404. You could send them to a real page that says 'Page not found' and add a javascript timer to send them to a better page after few seconds. PHP Code:
Code:
<script type="text/javascript"> |
I think, I've got it now. I think I was getting confused, the "200 OK" header was for an image file on the page. The page itself was properly returning a 404.
|
| All times are GMT +1. The time now is 12:15 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.