Jump to content
xisto Community
Amezis

404 On A Normal Page

Recommended Posts

Well, I am using a mod_rewrite script, making "http://forums.xisto.com/no_longer_exists/; a valid page even if it shows that the page could not be found. How can I add to the header with PHP that the page is not found, replacing the 200 status code (OK)?

I am not too sure what you mean here. Do you mean that you want to make it so that if a 404 appears on your website, it still thinks the page exists?

Share this post


Link to post
Share on other sites

No:

<?phpif ( page_exists ){	  // Do all normal stuff}else{	  /* Page doesn't exist, send a 404 error status in the header instead of the 200 status, and give the user a friendly 404 error page (I do not wish to use a redirect) */}?>

Share this post


Link to post
Share on other sites

But that's not what he wants to do.

Simply use the header() function within a script to overwrite the original status and send a 404 message:

header('HTTP/1.1 404 Not Found',true);

Share this post


Link to post
Share on other sites

Thanks Spectre. :)For those who didn't understand my question, I have a php file. If someone loads file.php?view=this_exists, everything is done normally. But if someone loads file.php?view=this_doesnt_exist, then the 404 error code is shown. I am using mod_rewrite, so file.php?view=this_exists is displayed as /this_exists.A search engine would not understand that /this_doesnt_exist doesn't exist unless the 404 header was sent. So I simply wanted to send a 404 in the header without using the apache error function since that wouldn't do the job.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.