Difference between revisions of "HTTP Error Codes"

From HE FAQ
Jump to: navigation, search
(How do I customize error messages like "Code 404: Not Found"?)
 
Line 12: Line 12:
  
 
It means that you had a request for a document in your site that did not exist. Typically this is the result of a bad URL in one of your documents which links to a non existent document, either a mistake, or one that you were planning on writing but haven't yet.
 
It means that you had a request for a document in your site that did not exist. Typically this is the result of a bad URL in one of your documents which links to a non existent document, either a mistake, or one that you were planning on writing but haven't yet.
 +
 +
 +
== What does "Code 403: Forbidden" mean? ==
 +
 +
This means that you tried to view something that the web server has been directed not to show.  Common reasons are:
 +
* You specified a directory as the URL, e.g. <nowiki>http://www.he.net/~rflyer</nowiki>, and there's no index page (index.html, index.htm, or index.php) in that directory.  If you want to be able to view the directory contents, you can use the line "Options Indexes" in an [[htaccess | .htaccess]].
 +
* You tried to load a page that isn't world-readable.  In Unix, every file has permissions that specify whether the file's owner, everyone, or no one, can read, edit, or execute the file.  You can change a file's permissions in most [[Uploading & Downloading Files | SFTP clients]] by right-clicking on them.
 +
* You tried to visit a directory with [[Limiting_Access | limited access]] and you didn't enter the right username and password.
 +
 +
 +
== What does "Code 500: Internal Server Error" mean? ==
 +
 +
There are a few things that can cause that.  If you're using MySQL for the page, check your MySQL settings (username, password, appropriate data, and that no tables need to be repaired).  Also check your [[htaccess | .htaccess]] settings, if you've changed them, to make sure they're correct.  Also try loading other web pages on your site; if other pages load, it's probably not actually a problem with the server.
  
  

Latest revision as of 17:03, 6 January 2012

This information only pertains to Hurricane Electric's Shared Web Hosting package. There may be different information in our other categories.

What is an HTTP response code?

HTTP response codes are the standard numbers associated web server error messages.

An example is:

404 Error: File not found


What does "Code 404: Not found" mean?

It means that you had a request for a document in your site that did not exist. Typically this is the result of a bad URL in one of your documents which links to a non existent document, either a mistake, or one that you were planning on writing but haven't yet.


What does "Code 403: Forbidden" mean?

This means that you tried to view something that the web server has been directed not to show. Common reasons are:

  • You specified a directory as the URL, e.g. http://www.he.net/~rflyer, and there's no index page (index.html, index.htm, or index.php) in that directory. If you want to be able to view the directory contents, you can use the line "Options Indexes" in an .htaccess.
  • You tried to load a page that isn't world-readable. In Unix, every file has permissions that specify whether the file's owner, everyone, or no one, can read, edit, or execute the file. You can change a file's permissions in most SFTP clients by right-clicking on them.
  • You tried to visit a directory with limited access and you didn't enter the right username and password.


What does "Code 500: Internal Server Error" mean?

There are a few things that can cause that. If you're using MySQL for the page, check your MySQL settings (username, password, appropriate data, and that no tables need to be repaired). Also check your .htaccess settings, if you've changed them, to make sure they're correct. Also try loading other web pages on your site; if other pages load, it's probably not actually a problem with the server.


What does Code 302 mean?

Code 302 Redirected requests result whenever you specify a directory for a URL. For example, if you specify:

http://www.he.net/~rflyer

the server redirects the browser to request:

http://www.he.net/~flyer/index.html

The server handles the redirection in this manner in conformance with HTTP standards. It is quite normal.


How do I customize error messages like "Code 404: Not Found"?

You can customize your error messages by creating or editing your .htaccess file.

Please note that .htaccess is not enabled for "Simple Virtual Host" accounts.

If you need this feature, please email support@he.net to request an upgrade of account type.

To create customized error pages, you need to create the following html documents:

  • 400.html
  • 401.html
  • 403.html
  • 404.html
  • 500.html

You can modify the contents of these documents however you please.

Next, you will need to create your customized .htaccess file.

Inside your public_html directory, or one of its subdirectories, you may have a file named .htaccess. If an .htaccess file isn't already there, then you can either create one online using the pico command in ssh, or create one in a text editor and upload it to the server using an ftp program. Now add the following lines to your .htaccess file:


ErrorDocument 400 URL
ErrorDocument 401 URL
ErrorDocument 403 URL
ErrorDocument 404 URL
ErrorDocument 500 URL

Make sure to replace where it says URL with the URL to that error message.

For example, your .htaccess file may look something like this:

ErrorDocument 400 /400.html
ErrorDocument 401 /401.html
ErrorDocument 403 /403.html
ErrorDocument 404 /404.html
ErrorDocument 500 /500.html

If you do not have your domain pointed to your account, you must use the fully qualified URL, like this:

ErrorDocument 400 http://he.net/~jdoe/400.html
ErrorDocument 401 http://he.net/~jdoe/401.html
ErrorDocument 403 http://he.net/~jdoe/403.html
ErrorDocument 404 http://he.net/~jdoe/404.html
ErrorDocument 500 http://he.net/~jdoe/500.html

You also have the option of just puting in the text or HTML to display in your .htaccess file.

For example:

ErrorDocument 404 "<h2><i>404 Error:</i> File not found</h2>"

Note that when you specify an ErrorDocument that points to a remote URL (ie. anything with a method such as "http" in front of it) Apache will send a redirect to the client to tell it where to find the document, even if the document ends up being on the same server. This has several implications, the most important being that if you use an "ErrorDocument 401" directive then it must refer to a local document. This results from the nature of the HTTP basic authentication scheme.