Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 288
  • Last Modified:

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!
0
hibbsusan
Asked:
hibbsusan
  • 9
  • 6
  • 5
  • +2
1 Solution
 
Pratima PharandeCommented:
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
 
Hugh McCurdyCommented:
If you still want help, it would help if you provided the URL of the Google document.
0
 
Dave BaldwinFixer of ProblemsCommented:
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
hibbsusanAuthor Commented:
hmccurdy,

this is the document I was referring to:

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

Thanks!
0
 
user_nCommented:
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
 
Hugh McCurdyCommented:
Thanks for the URL.  It appears you already have good answers.  If wrong, post again and I'll come back here to look.
0
 
user_nCommented:
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
 
user_nCommented:
I just know something fro http
0
 
user_nCommented:
and html
0
 
hibbsusanAuthor Commented:
So what code do I need to put in my 404 document..?

0
 
Dave BaldwinFixer of ProblemsCommented:
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
 
hibbsusanAuthor Commented:
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
 
user_nCommented:
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
 
hibbsusanAuthor Commented:
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
 
Dave BaldwinFixer of ProblemsCommented:
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
 
hibbsusanAuthor Commented:
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
 
Dave BaldwinFixer of ProblemsCommented:
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
 
hibbsusanAuthor Commented:
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
 
Dave BaldwinFixer of ProblemsCommented:
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
 
user_nCommented:
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 9
  • 6
  • 5
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now