You can create custom error pages in cPanel by navigating to the Error Pages section under Advanced options, designing your custom page, and then adding the appropriate ErrorDocument directive to your .htaccess file in the public_html directory. This allows you to display branded, helpful messages when visitors encounter errors like 404 (page not found) or 500 (server error) instead of showing generic browser error messages.
What Are Custom Error Pages?
Custom error pages are branded web pages that display when visitors encounter errors on your website. Instead of seeing a plain browser error message, visitors see a page you design that matches your site's look and feel. These pages appear when someone enters an incorrect URL, tries to access a restricted area, or when your server encounters technical issues.
Common HTTP Error Types
Understanding the different error types helps you create appropriate custom pages for each situation:
- 400 (Bad Request): The server cannot process the request due to client error
- 401 (Authorization Required): The visitor needs to authenticate to access the requested page
- 403 (Forbidden): The visitor is not allowed to access the requested resource
- 404 (Wrong Page): The requested page does not exist on your server
- 500 (Internal Server Error): The server encountered an unexpected condition
How to Create Custom Error Pages in cPanel
Follow these steps to set up custom error pages through your OBHost cPanel account:
- Log into your cPanel account
- Navigate to the Advanced section
- Click on Error Pages
- Select the domain you want to customize
- Choose the error code you want to customize (400, 401, 403, 404, or 500)
- Design your custom error page using HTML
- Click Save to create the error page
Activating Custom Error Pages with .htaccess
After creating your custom error pages in cPanel, you need to activate them by editing your .htaccess file:
- Access your public_html directory through File Manager or FTP
- Open or create a file named .htaccess
- Add the appropriate ErrorDocument directives for each custom page
Example directives to add to your .htaccess file:
- For custom 404 error page: ErrorDocument 404 /404.shtml
- For custom 500 error page: ErrorDocument 500 /500.shtml
- For custom 403 error page: ErrorDocument 403 /403.shtml
Dynamic Tags for Error Pages
When creating your custom error pages, you can include dynamic tags that display helpful information to visitors:
- Referring URL: Shows the previous page the visitor was viewing
- Visitor's IP Address: Displays the visitor's IP address
- Requested URL: Shows the URL the visitor attempted to access
- Server Name: Displays your website's server name
- Visitor's Browser: Shows the browser type (Chrome, Firefox, Safari, etc.)
- Redirect Status Code: Displays redirect codes in the 300-307 range
Best Practices for Custom Error Pages
Create effective custom error pages by following these guidelines:
- Keep the design consistent with your website's branding
- Include a search box to help visitors find what they need
- Provide links to your homepage and main navigation
- Use friendly, helpful language instead of technical jargon
- Add contact information or support links
- Consider including popular pages or recent content
Frequently Asked Questions
Where should I save my custom error page files?
Save your custom error page files in your website's root directory (public_html). Common naming conventions include 404.shtml, 500.shtml, and so on. The .htaccess file should reference the exact filename and location you use.
Why isn't my custom error page showing up?
If your custom error page isn't displaying, check that the .htaccess file is in the correct directory (public_html), verify the ErrorDocument directive syntax is correct, ensure the error page file exists at the specified path, and confirm your file permissions allow the server to read the files.
Can I use HTML and CSS in custom error pages?
Yes, you can use full HTML, CSS, and even JavaScript in your custom error pages. This allows you to create visually appealing pages that match your website's design. Just remember to use .shtml or .html extensions and reference any external CSS or image files with absolute URLs.
Do I need separate error pages for each domain on my account?
Yes, if you host multiple domains on your account, you can create unique custom error pages for each domain. When setting up error pages in cPanel, select the specific domain first, then create the custom pages for that domain.