Solved

what is http status code?

Posted on 2011-09-18
23
263 Views
Last Modified: 2012-05-12
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!
0
Comment
Question by:hibbsusan
  • 9
  • 6
  • 5
  • +2
23 Comments
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 36558276
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
0
 
LVL 13

Expert Comment

by:Hugh McCurdy
ID: 36558487
If you still want help, it would help if you provided the URL of the Google document.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 36558568
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

0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Comment

by:hibbsusan
ID: 36558626
hmccurdy,

this is the document I was referring to:

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

Thanks!
0
 
LVL 9

Accepted Solution

by:
user_n earned 500 total points
ID: 36559071
It means that your error page should be returned in http response with 404 status code.
  Response      = Status-Line               ; Section 6.1
                       *(( general-header        ; Section 4.5
                        | response-header        ; Section 6.2
                        | entity-header ) CRLF)  ; Section 7.1
                       CRLF
                       [ message-body ]          ; Section 7.2


your html code will be the message-body
http://tools.ietf.org/html/rfc2616#page-39  surch response. If you want to see how http response actaly look you can use wireshark
0
 
LVL 9

Expert Comment

by:user_n
ID: 36559278
0
 
LVL 13

Expert Comment

by:Hugh McCurdy
ID: 36560257
Thanks for the URL.  It appears you already have good answers.  If wrong, post again and I'll come back here to look.
0
 
LVL 9

Expert Comment

by:user_n
ID: 36560493
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.
0
 
LVL 9

Expert Comment

by:user_n
ID: 36560511
I just know something fro http
0
 
LVL 9

Expert Comment

by:user_n
ID: 36560513
and html
0
 

Author Comment

by:hibbsusan
ID: 36563221
So what code do I need to put in my 404 document..?

0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 36563283
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?
0
 

Author Comment

by:hibbsusan
ID: 36563321
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?
0
 
LVL 9

Expert Comment

by:user_n
ID: 36563462
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.
0
 
LVL 9

Expert Comment

by:user_n
ID: 36563534
0
 

Author Comment

by:hibbsusan
ID: 36563591
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.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 36563818
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'.
0
 

Author Comment

by:hibbsusan
ID: 36564439
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..
0
 
LVL 9

Expert Comment

by:user_n
ID: 36564721
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 36565232
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'.
0
 

Author Comment

by:hibbsusan
ID: 36569630
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!
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 36569748
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.
0
 
LVL 9

Expert Comment

by:user_n
ID: 36571676
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question