You can customize your error pages right from your hosting account using cPanel!
- Login to cPanel as described in your welcome email.
- Look for the “Advanced Tools” box and click on “Custom Error Pages” icon.
- The most common error pages are displayed for you to edit. In most cases you won’t need more than that, but you can also edit all the “HTTP Error Status Codes” if you want.
- Clic one of the error pages from the list to edit it.
- When you finish editing your status page, save it and then open the “.htaccess” file from your root folder (use the file manager included with cPanel or edit it connecting by FTP). If you don’t see the “.htaccess” file, please make sure that you can see hidden files. With the “show hidden files” option enabled, if you still don’t see the file, just create it and place it in your main web folder.
- If you’ve created the “404 (Not Found)” custom error page, write the following in the “.htaccess” file:
ErrorDocument 404 /404.shtml
For any other custom error page, just replace the number from the line above, with the number of the error code.
For multiple customized error pages, write multiple lines in your “.htaccess” file. One line for each custom error page.
So let’s make an example:
If you’ve edited all the common Error Codes Pages from cPanel, your “.htaccess” file should have the following lines:
# Custom Error Pages ErrorDocument 400 /400.shtml ErrorDocument 401 /401.shtml ErrorDocument 403 /403.shtml ErrorDocument 404 /404.shtml ErrorDocument 500 /500.shtml
If you didn’t create the “.htaccess” file manually (it was already there and it already had some text in it), just insert those lines at the bottom of the file and save it.
After customizing your error pages, you can preview them adding the file name of the custom error page at the end of your web page URL (IE: www.yourdomain.com/400.shtml). You can easily check that your 404 custom error page is working by entering a non existent url under your domain name.
Please take into account that some scripts like WordPress, for example, have their own 404 custom error page engine and will not take into account your 404.shtml file, so you will have to customize that error code from your template in WordPress.
If you don’t know how to code in HTML, you can use any WYSIWYG editor like NVU (free) or Adobe Dreamweaver (commercial) to create your custom error page and then paste all the code in the cPanel editor. If you use images, please make sure that you upload them to the server by FTP or using the File Manager in cPanel and reference them with an absolute url (starting with “/”).
How to revert back to the default Error Pages?
If you want to restore the original error pages, just delete the error page file from the public_html folder (404.shtml, 403.shtml, etc…) and delete the lines from the “.htaccess” file.
Please feel free to comment if you have any doubts regarding this article.