This article explains how to set up custom error documents for your server. Instead of a plain 404 Not Found or 500 Internal Server Error page, you can show your visitors a customized page that matches your site design.
READ ME FIRST
The publishing of this information does not imply support of this article. This article is provided solely as a courtesy to our customers. Please take a moment to review the Statement of SupportStatement of Support.
You should make these pages simple to generate - plain HTML is best. 404 pages especially are needed frequently, and the server will spend a lot of resources if it has to process a complex custom page every time someone generates a 404 request.
.htaccess file will override the server default error pages, directing Apache to use custom pages instead.
Using custom error pages
You MUST add a "/" at the beginning of the path to your custom error document. The "/" references the document root of your server (
httpdocs by default). The path to your error document should be from the document root, regardless of whether you upload your
.htaccess file to the document root directory or to a subdirectory.
That's it! Your change will take affect within minutes. You can test your error handling by trying to generate the error yourself. For example, to test a new 404 Not Found page, try visiting http://example.com/this_subfolder_does_not_exist/. Replace example.com with your own domain name. You should see your custom Not Found page.
Common client and server errors
For more information about different types of Status Codes, please see this page at w3.org:
- Create your error pages. The documents can have any name. The example will use not_found.html.
- Upload your error pages to your server using FTP. These pages should go inside your html (
/home/00000/domains/example.com/html/) directory or a subdirectory. The example will use the subdirectory
/home/00000/domains/example.com/html/errors/) for error documents.
- Upload your error pages to your server using FTP. These pages should go inside your httpdocs directory or a subdirectory. The example will use the subdirectory
errors/for error documents.
- Create an .htaccess file with the following lines, or add them to your existing .htaccess file:
- Add the following lines to your .htaccess file:
ErrorDocument 404 /errors/not_found.html
You can add multiple types of custom error documents:
ErrorDocument 403 /errors/forbidden.html ErrorDocument 404 /errors/not_found.html
- Upload your .htaccess file to your html directory via FTP. You can also upload it to a subfolder if you want it to handle error requests only for the subfolder. A subfolder .htaccess file overrides a higher-level one.
- Upload your .htaccess file to your httpdocs directory via FTP. You can also upload it to a subfolder if you want it to handle error requests only for the subfolder. A subfolder .htaccess file overrides a higher-level one.
- 401 Unauthorized - user is not logged into a password-protected area
- 403 Forbidden - browser does not have permission to perform the requested action
- 404 Not Found - browser cannot find the requested document on the server
- 500 Internal Server Error - server was unable to finish processing the request
- 502 Bad Gateway - server received an invalid response from an upstream server
- 503 Service Unavailable - server is currently unable to process the request