Click to See Complete Forum and Search --> : Generate Error 404 through PHP


Nap
12-03-2006, 09:08 PM
Hi,
I have a page I would like to protect by making people think it doesn't exist.
The PHP requires a parameter to be sent in the URL and if it's not there, I would like the browser to respond with the standard 404 Error - File not found!.

I have tried using:ob_end_clean();
header( 'HTTP/1.0 404 Not Found' );but it doesn't generate the error page. (Simply returns a blank page.) Do I need to build the header with other information?

Can anyone please help?

Cheers,
Nap

Nap
12-03-2006, 09:16 PM
Since my server has a custom error 404.htm page, I've been able to redirect to it.

However, if there isn't a custom 404 error page, how can you get the browser to show the default screen?

Cheers,
Nap

NogDog
12-03-2006, 09:49 PM
I think by the time you get to the point where PHP is processing your script, you've passed the point where Apache would redirect to a 404 page if it couldn't find the requested file; so you'll probably have to explicitly redirect as you're doing now. (Should you find out otherwise, I'd be interested to know. :) )