How do I setup custom error pages for my website?

edited December 2012 in Web Development
Whenever an error occurs on the server, it displays an error page to the visitor with information and tips about the possible cause for the error. These error pages do not match your website''s layout and are sometimes too general. You may want to set up your custom error pages, which should be displayed to your visitors whenever an error occurs.

There are two methods that could be used to achieve this.

1) Editing the domain/subdomain options in the Subdomain Manager section.

We have embedded the option to set a custom error page for server errors 400, 401, 403 and 404 inside the Subdomain Manager section of your Web Hosting Control Panel (Site Options > Subdomain Manager). Find your domain in the list and click on the "edit" icon next to it. You are now able to edit the error page options. You should see the following options:

Set error 400 page: /custom400.html
Set error 401 page: /custom401.html
Set error 403 page: /custom403.html
Set error 404 page: /custom404.html

Initially, all error pages are set to "Default". To set a custom error page, choose "Custom URL" and enter the path to the corresponding error page in the field. If you haven''t created one yet, do this first and then get back to the Subdomain Manager section to update the settings.

2) Using .htaccess

Just like with the first method, which is described above, you must create the corresponding error page(s) first. When ready, open the File Manager section of your Hosting Control Panel (Site Options > File Manager) and navigate to your domain/subdomain folder - it usually has the same name as your domain/subdomain and is located inside the www/ directory. Inside the domain folder create an empty file called .htaccess using the form located at the top of the File Manager section. Then edit the .htaccess file with the plain-text editor and insert the following code:

ErrorDocument 400 /custom400.html
ErrorDocument 401 /custom401.html
ErrorDocument 403 /custom403.html
ErrorDocument 404 /custom404.html

In the above example the custom 404 error page is located in the same folder as the .htaccess file and it is called custom400.html. Edit the path and the name of each page accordingly to reflect the actual names and location of your custom error pages. This method would work no matter what the settings in the Subdomain Manager section are.
Sign In or Register to comment.