Jump to content

Archived

This topic is now archived and is closed to further replies.

Millar

PHP force 404 Error

Recommended Posts

I want certain pages to return the 404 error page that the server automatically generates. I tried the following code and it didn't work, what am I doing wrong?

My Code:
[code]header("HTTP/1.1 404 Not Found");[/code]

Thanks.

Share this post


Link to post
Share on other sites
The whole file just looks like this -
[code]<?
header("HTTP/1.1 404 Not Found");
exit;
?>[/code]

Share this post


Link to post
Share on other sites
If you're trying to create you're own Custom 404 Pages, you'll have to edit the 404.shtml in your Apache or IIS configuration

Most of the time you can just have all you're error pages do the same thing and just send the error message to one of you're PHP scripts along with whatever information you want.
But you have to do that in that 404.shtml file

That is if that's what you're trying to do

Share this post


Link to post
Share on other sites
No. I have the error pages working fine. I just want PHP to output my servers 404 on a page that does. Exist so that I can force the error page for invalid query strings etc.

Share this post


Link to post
Share on other sites
Well, I guess if you're not going to have anything else on the error page other than......the 404

you could just flat out redirect to ajflkjdslfkjsdlkajflakf.html
which I'd assume doesn't exist

but you'd do it through HTML and not a PHP function....meaning
echo out
[quote]
<META http-equiv="refresh" content="0; URL=somerandomarrayofletters.html">[/quote]

Share this post


Link to post
Share on other sites
Well id rather do it via the proper way. Anyone know why its not working?

Share this post


Link to post
Share on other sites
Would it not be confusing for a user to send a 404 error for something like a bad query string? Would it not be better to give them a message saying what the problem was etc?

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.