LochStudios  /  Help Centre  /  cPanel  /  Set up custom error pages

Set up custom error pages

Create branded error pages for HTTP errors like 404 and 500 to improve user experience when problems occur.

Updated

When visitors encounter an error (like a missing page or server problem), a generic error message appears. Custom error pages let you display a branded page instead—with helpful navigation, your logo, or a friendly message—keeping visitors on your site and maintaining professionalism.

Common HTTP error codes

| Code | Meaning | Example |
|------|---------|---------|
| 400 | Bad Request | Malformed request |
| 401 | Unauthorized | Missing login credentials |
| 403 | Forbidden | Permission denied |
| 404 | Not Found | Page doesn't exist |
| 500 | Internal Server Error | Server problem |
| 502 | Bad Gateway | Temporary server issue |
| 503 | Service Unavailable | Server overloaded or offline |

Creating custom error pages

Step 1: Create your error page files

Use an HTML editor or cPanel's file manager to create error page files. Name them clearly—for example:

  • error404.html (for 404 errors)
  • error500.html (for 500 errors)
  • error403.html (for 403 errors)

Keep the design simple and include:
- Your site logo or branding
- A clear message (e.g., "Sorry, this page doesn't exist")
- A link to your homepage or site map
- Contact information

Example 404 page (save as error404.html):

<!DOCTYPE html>
<html>
<head>
  <title>Page Not Found</title>
  <style>
    body { font-family: Arial, sans-serif; background: #f0f0f0; margin: 0; padding: 20px; }
    .container { max-width: 600px; margin: 0 auto; background: white; padding: 40px; border-radius: 5px; }
    h1 { color: #d9534f; }
  </style>
</head>
<body>
  <div class="container">
    <h1>404 - Page Not Found</h1>
    <p>Sorry, the page you're looking for doesn't exist.</p>
    <p><a href="/">Return to Home</a></p>
  </div>
</body>
</html>

Step 2: Upload your error pages

  1. In cPanel, navigate to FilesFile Manager.
  2. Go to your public_html directory (or the domain's root).
  3. Upload your error page files (e.g., error404.html, error500.html).

Step 3: Set up error page redirects

1. In cPanel, navigate to AdvancedError Pages.
2. Select your domain from the dropdown (if available).
3. For each error code you want to customize (e.g., 404):
- Click the error code.
- Enter the path to your error page file (e.g., /error404.html).
- Click Save.
4. Repeat for any other errors (500, 403, etc.).

Alternative: Using .htaccess (Advanced)

If cPanel's Error Pages tool isn't available, you can add custom error directives to your .htaccess file:

1. In File Manager, navigate to public_html and show hidden files (Settings → Show hidden files).
2. Edit the .htaccess file (or create one if it doesn't exist).
3. Add lines like:
```
ErrorDocument 404 /error404.html
ErrorDocument 500 /error500.html
ErrorDocument 403 /error403.html
```
4. Save the file.

Testing your custom error pages

  1. For a 404 test, visit: http://yourdomain.com/nonexistent-page-xyz
  2. For a 500 test (if you can trigger one safely), check your error page displays correctly.
  3. Verify the page includes your branding and helpful navigation.

Best practices

  • Keep it branded: Use your site's colors, logo, and tone so visitors know they're still on your site.
  • Provide navigation: Always include a link to your homepage or main menu.
  • Be helpful: For 404, suggest searching the site or browsing categories.
  • Keep file size small: Error pages load quickly, so use minimal CSS and no large images.
  • Test before deploying: Create a test version at a different URL first.
  • One page per error: Avoid creating one generic page for all errors—404 should say "page not found", 500 should say "server error".

Tips

  • Your error page file should be a static HTML file (not a PHP file), so it works even if PHP is broken.
  • If your web server uses Apache, check .htaccess syntax carefully or you might break your site.
  • Contact your hosting provider if custom error pages aren't working or if Error Pages tool is unavailable.

Was this article helpful?

← Back to cPanel