View Full Version : Trigger an Error404 with PHP

07-14-2008, 12:40 PM

I need to produce an Error 404 with PHP.

I want some users be able to access the file.php (based on their permissions) if they are allowed to.

For the ones who don't have access to file.php, I don't want to display a "You are not allowed" kind of message, but an Error 404, as if the file does not exist.

How can I do that? I don't want to use the header command to another file, since it would display the name of the second file in the address bar.

07-14-2008, 01:03 PM
See http://in.php.net/header,

header("HTTP/1.0 404 Not Found");

07-15-2008, 07:51 PM
Thanks for the suggestion.

Unfortunately, it does not produce a Error 404 for me, but a blank page instead. What could be the problem?

What about


header("Location: nonexistent404.php");


and produce a real 404 error?