Creating custom error pages using .htaccess
One of the many things one can do to make their website a little more professional-looking is to create custom error pages which will be displayed instead of the default generic error pages such as "404 - File Not Found". In addition to there being practical uses to this (example: one can include an option to allow users to notify you of dead links or even setup a script to notify you automatically) an attractive looking custom error page can make even your mistakes look good.
While the HostRocket Control Panel includes a "Custom Error Pages" tool which can be used to easily setup custom error documents, if preferred, one can also accomplish this manually by modifying the .htaccess file in their public_html directory.
The most commonly encountered error messages are:
400 - Bad Request
401 - Authorization Required
403 - Forbidden
404 - Not Found
500 - Internal Server Error
In order to have custom error pages that you create yourself be displayed instead of the default server error, one would add directives similar to the following to their /public_html/.htaccess file:
ErrorDocument 400 /400.html
ErrorDocument 401 /401.html
ErrorDocument 403 /403.html
ErrorDocument 404 /404.html
ErrorDocument 500 /500.html
The above assumes that one names the files ###.html where ### represents the number of the error (one can name the files anything they wish and modify the directives accordingly) and places the files within their public_html folder. If storing the files within a subdirectory is preferred this can also be done. The following example shows the appropriate directives to use if one were to upload their custom error pages to a subdirectory named "err":
ErrorDocument 400 /err/400.html
ErrorDocument 401 /err/401.html
ErrorDocument 403 /err/403.html
ErrorDocument 404 /err/404.html
ErrorDocument 500 /err/500.html
Things To Note
In Microsoft Internet Explorer version 5.x and later, by default Microsoft's own "friendly" error pages will be displayed unless your custom error document is 512 bytes or larger. So in order to make sure that your error pages are displayed make sure that the size of all custom error pages exceed 512 bytes.
Was this answer helpful?
One of the more common/popular uses of .htaccess is to password protect specific directories...
What is .htaccess? The Apache Web server utilizes a per-directory access and configuration...
By default when accessing any directory which does not contain an index file (ex:...
If your website is using a long URL like example.com/files/folder/sitemap.html, you can change it...
While all HostRocket plans include plenty of bandwidth (transfer) nobody ever has enough...