Solved

what is http status code?

Posted on 2011-09-18
23
238 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
Comment Utility
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
Comment Utility
If you still want help, it would help if you provided the URL of the Google document.
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
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
 

Author Comment

by:hibbsusan
Comment Utility
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
Comment Utility
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
Comment Utility
0
 
LVL 13

Expert Comment

by:Hugh McCurdy
Comment Utility
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
Comment Utility
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
Comment Utility
I just know something fro http
0
 
LVL 9

Expert Comment

by:user_n
Comment Utility
and html
0
 

Author Comment

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

0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
0
 

Author Comment

by:hibbsusan
Comment Utility
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 82

Expert Comment

by:Dave Baldwin
Comment Utility
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
Comment Utility
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
Comment Utility
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
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
Comment Utility
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 82

Expert Comment

by:Dave Baldwin
Comment Utility
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
Comment Utility
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now