Link to home
Start Free TrialLog in
Avatar of hibbsusan
hibbsusan

asked on

what is http status code?

i'm making some custom error pages. The google help for webmasters page instructs like this:

No matter how beautiful and useful your custom 404 page, you probably don't want it to appear in Google search results. In order to prevent 404 pages from being indexed by Google and other search engines, make sure that your webserver returns an actual 404 HTTP status code when a missing page is requested.

return an actual 404 HTTP status code?

does that mean simply to put

<!--#echo var="REDIRECT_STATUS" -->

Open in new window


in the head of the document?

Thanks!
Avatar of Pratima
Pratima
Flag of India image

I think you need this

header(‘HTTP/1.0 404 Not found’);

or
<?php
if ($this->error->code == '404') {
      header("HTTP/1.0 404 Not Found");
} ?>


refer
http://docs.joomla.org/Custom_error_pages
http://herselfswebtools.com/2008/08/how-to-force-an-http-error-code-from-php.html
If you still want help, it would help if you provided the URL of the Google document.
No, it doesn't mean that.  Web servers return correct error codes when they return their own error pages.  In Apache you can define your own Error Pages in your .htaccess like below and have them return the proper codes.  I don't know how to create your own Error pages in IIS.
ErrorDocument 400 /400.html
ErrorDocument 401 /401.html
ErrorDocument 403 /403.html
ErrorDocument 404 /404.html
ErrorDocument 500 /500.html

Open in new window

Avatar of hibbsusan
hibbsusan

ASKER

hmccurdy,

this is the document I was referring to:

http://www.google.com/support/webmasters/bin/answer.py?answer=93641

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of user_n
user_n
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the URL.  It appears you already have good answers.  If wrong, post again and I'll come back here to look.
I don't have a ready answere. You just have to write the page and send it in the body of  the 404 http response when the url/web page does not exist. How it should be done depends from the opportunity of the scripting language and http server that you use.
I just know something fro http
and html
So what code do I need to put in my 404 document..?

Normally, the server sets the return code.  You can't set it after any content has been sent because it's part of the response header.  You can probably do it in PHP or maybe ASP but you can't do it with HTML.

What programming language are you using and what kind of web server?
i'm making my custom error pages in php, with some javascript (google analytics). The server is Apache (I guess linux interface (but I don't know what either apache or linux really is)) Intel Dual core.

Is that the information you asked for?
http://webdesign.about.com/od/apache/ht/ht404apache.htm


I think that you just should change the code in 404.html with your code. And this page will be returned in all cases. There would be no custom error pages. There will be a custom (one) error page.
I think that you just should change the code in 404.html with your code. And this page will be returned in all cases. There would be no custom error pages. There will be a custom (one) error page.

I'm sorry; I don't understand this at all.
If you're on shared hosting, you can't follow those instructions because you won't have access to the 'httpd.conf' file.  When you connect by FTP, do you have a file in your web root call '.htaccess'?  My first post above shows the format of the lines that you need in '.htaccess' so that Apache will use your custom error pages.  They can be named what ever you want but they should be in the web root along with '.htaccess'.
Yes, I have my own .htaccess file: it's a dedicated server. Is that the only place the 404 docs can be set from? I originally created them using cPanel, and it seems like it didn't modify the .htaccess. That file is blank. I can't imagine it would make the files without making the necessary http code returned..
If it's dedicated then it might be modifying 'httpd.conf'.  There are usually a set of instructions for error handling there.  On shared hosting we use '.htaccess' because we don't have access to 'httpd.conf'.
okay.. and I would add the same lines of code.

I put a php mailer function in so I could track the IPs of people who are getting 404s. Many are search spiders. Does that mean they're indexing my error pages.

Also, since I have one directory where I want a specific error message, I have a special .htaccess file in there which has the line:

ErrorDocument 404 http://www.isco.net/templates/404_temp.php

Open in new window


will modifying this httpd.conf over-ride this in anyway. Is my .htaccess file doing the job of returning the error codes appropriately so as not to get indexed by search engines?

Thanks for taking your time to explain all this!
The '.htaccess' file in a directory overrides any previous directives as far as I know.   So that one should work for that directory and any sub-directories under that one.