An error page displays to visitors when they try to access a web page that has a problem. Each type of problem has its own status code. For example, 404
is the code for “Not Found” and shows when the web server can’t find the page requested.
By default, cPanel creates error pages for the most common errors for any domains on the account. These include:
- 400 - Bad Request - The server cannot handle the visitor’s request because it is corrupt or unable to understand it.
- 401 - Unauthorized - This status code means that the user cannot access the page without completing the authentication process. Typically this page is displayed to visitors who cannot complete the Password Protection of a web directory.
- 403 - Forbidden - Access to the requested web page by the visitor is forbidden. This can be caused by file or folder permissions or specific rules set in the .htaccess file. For example, “deny from IP address”.
- 404 - Not Found - The requested page cannot be found. A typical reason for this error code is a non-existent page or improperly rewritten(Mod Rewrite) - request.
- 500 - Internal Server Error - Something with the communication between your website and the Web Server went wrong. Typically this can be caused by - **incorrect permissions set for the files and folders of your website or if the website is producing some error when the Web Server is executing the website’s code.
Note:
Custom error pages are optional. If there is no custom page for a particular error code, your server will display a default error page. However, for 404 - Not Found
errors, for example, it can be helpful to display popular links or a link to your search page.
This tutorial will show you how to edit the most common error pages or create new ones for any error type.
How to customize Error Pages in cPanel
Customizing your cPanel Error pages is relatively simple. You can use the error page builder to insert snippets, such as Referring URL, Visitors’ IP, Server name, Browser, and more.
You can add or customize pages for any error code beginning with 4 or 5.
Under the Advanced Panel, click the Error Pages icon.
You will need to choose the domain to manage the error pages by selecting it in the dropdown box under “Step 1 - Select Domain to Manage Error Pages”.
The next step is to click one of the error pages to edit. There are two tabs containing links to the pages:
- Edit Common Error Codes
- Show All HTTP Error Status Codes
For most webmasters, Error Pages for the common error codes should be sufficient. However, you may want to consider creating pages for the following codes:
502 - Bad gateway
503 - Service unavailable
504 - Gateway timeout
Let’s alter the 404 - Not found
error page in this example. To do this, click on the relevant link under the “Edit Common Error Codes” tab.
The default error pages use code in the following format:
<!--#set var="code" value="404" -->
<!--#set var="reason" value="Not Found" -->
<!--#set var="msg" value="The server cannot find the requested page:" -->
<!--#include virtual="cp_errordocument.shtml" -->
This injects variables or “Tags” for the error code, reason, and a message into a default template. This can be found at yourdomain.com/cp_errordocument.shtml
.
You can alter or delete this code \ template. At the top of the page, you can click several variables to insert information about the error into your page, including:
Referring URL
Visitor's IP address
Requested URL
Server Name
Visitor's Browser
Redirect Status Code
You can use these and any custom HTML to create a more informative error page.
For example, on 404
pages, you may wish to include links to other parts of your site or even a link to your search page. See the FAQs below for best practices on customizing your 404
page.
At the bottom of the page, click “Save” to save any changes.
Troubleshooting \ FAQs
What should you include on your custom `404` page?
Google provides some suggestions to keep your users on your site:
- Tell your users that the page cannot be found. Use “friendly and inviting” language.
- Make your 404-page look and feel the same as your main site. Include the same navigation elements.
- Consider adding links to your most popular articles and home page.
- Think about ways for your users to report a broken link.
- Do not include your 404 page in Google’s search results by ensuring it returns an actual 404 HTTP status code.