How to Set Up Custom Error Pages in cPanel
SEO guide explaining how to set up custom error pages in cpanel. Learn the best practices, setups, and automation tricks.
Why custom error pages matter
Every website produces errors: links that point to deleted pages, typos in URLs, blocked directories and occasional server failures. A default Apache error page is plain, unbranded and offers visitors nowhere to go. A good custom error page keeps the site’s navigation, explains what happened in plain language and helps people find what they were looking for.
There is also a technical side that is easy to get wrong. Search engines rely on the HTTP status code, not the text on the page, to decide whether a URL exists. A friendly page that says “not found” but returns 200 OK is treated as a real page, which wastes crawl budget and can leave dead URLs indexed. This guide shows how to set up custom pages in cPanel while keeping status codes correct.
Inspect Any Domain and Web Hosting Instantly
Inspect the infrastructure of any domain or website in seconds using TLDix WHOIS Domain, Hosting Lookup and Domain Oracle (AI).
The status codes you will customise
| Code | Meaning | Typical cause | Correct behaviour |
|---|---|---|---|
| 400 | Bad Request | Malformed request or URL | Short explanation, link home |
| 401 | Unauthorized | Password-protected directory | Prompt to log in |
| 403 | Forbidden | Blocked directory, IP deny rule, permissions | Explain access is restricted |
| 404 | Not Found | Deleted or mistyped URL | Search box, popular links, return 404 |
| 410 | Gone | Content removed on purpose | Signals permanent removal |
| 500 | Internal Server Error | Script errors, bad .htaccess rule | Apologise, keep page simple and static |
| 503 | Service Unavailable | Maintenance, overload | Return 503 with Retry-After during maintenance |
The 404 page gets by far the most traffic, so start there, then add 403 and 500.
Using the cPanel Error Pages tool
Open Advanced > Error Pages in cPanel. If your theme does not show it, your host may have disabled the feature, and you can use the .htaccess method instead.
- Choose the domain from the Managing dropdown.
- Select a code from the common list, such as 404 (Not Found), or open the full list for others.
- Write or paste your HTML in the editor. Buttons let you insert server-side include tags such as the referring URL, the requested URL and the visitor’s IP.
- Click Save.
cPanel saves the page as a file like 404.shtml in the domain’s document root. The .shtml extension tells Apache to process server-side includes, which is how the dynamic tags work. On standard cPanel servers, Apache is configured to look for these files automatically, so no further setup is needed.
A simple, useful 404 page
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Page not found</title>
<meta name="robots" content="noindex">
<link rel="stylesheet" href="/assets/css/site.css">
</head>
<body>
<h1>Sorry, we can’t find that page</h1>
<p>The address <!--#echo var="REQUEST_URI" --> may be mistyped or the page has moved.</p>
<p><a href="/">Go to the homepage</a> or try the search below.</p>
</body>
</html>
Use root-relative paths (starting with /) for stylesheets, images and links. Error pages are served at whatever URL the visitor requested, so relative paths like css/site.css break on deeper URLs such as /blog/old/post.
Setting error pages with .htaccess
If you prefer manual control, or want to use plain .html or .php files, add ErrorDocument directives to the .htaccess file in your document root. You can edit it with File Manager (enable “Show Hidden Files”).
ErrorDocument 400 /errors/400.html
ErrorDocument 403 /errors/403.html
ErrorDocument 404 /errors/404.html
ErrorDocument 500 /errors/500.html
Back up the existing .htaccess before editing. A typo in this file can itself cause a 500 error for the whole site.
The full-URL mistake
Apache allows an absolute URL in ErrorDocument, but this changes the behaviour completely:
# Wrong: sends a 302 redirect, the original URL never returns 404
ErrorDocument 404 https://example.com/404.html
# Right: serves the page internally with a 404 status
ErrorDocument 404 /404.html
With the full URL, the visitor and the crawler receive a redirect to a page that loads with 200 OK. The broken URL never reports a 404, which is the classic soft 404 pattern. Always use a local path.
Avoiding soft 404s
A soft 404 happens when a page tells people the content does not exist, while the server reports success. Search engines detect many of these and flag them in reports such as Google Search Console’s page indexing report, but you should not rely on detection. Common causes include:
- Redirecting all missing URLs to the homepage. Mass redirects to an unrelated page are often treated as soft 404s. Redirect only when there is a genuinely equivalent replacement page, using a 301.
- Error pages built as normal CMS pages, for example a “Not found” page created in the editor and linked via redirect.
- Empty search or category pages that say “no results” but return 200. Consider returning 404 or adding
noindexfor empty listings. - PHP error pages without a status header. If you use a PHP script as an error handler outside of Apache’s ErrorDocument flow, set the code explicitly:
<?php http_response_code(404); ?>
When content is removed permanently with no replacement, returning 410 Gone is an option that signals intent clearly; a plain 404 is also acceptable. For more on how status codes and site structure affect search, see our article on domain and TLD SEO factors.
WordPress and other CMS platforms
On WordPress, Joomla, Drupal and most modern frameworks, a rewrite rule sends every request that is not a real file to the application’s front controller. That means Apache never sees a 404 for normal page URLs; the CMS decides and renders its own not-found template. A cPanel 404.shtml will only appear for requests that bypass the CMS, such as missing static files in some configurations.
- WordPress: customise the theme’s
404.phptemplate (in a child theme so updates do not overwrite it). WordPress sends the 404 status automatically when it renders this template. - Frameworks: use the built-in error handler or exception renderer rather than a server-level page.
- Plugins that redirect 404s to the homepage should be configured carefully or removed, for the soft 404 reasons above.
Keep a static 500 page at server level even with a CMS. When PHP or the database fails, the CMS cannot render its own error template, so a plain HTML fallback is all that remains.
Testing your error pages
Never trust how an error page looks in a browser; check the status line. With curl from your computer or the cPanel Terminal:
curl -I https://example.com/this-page-does-not-exist
HTTP/2 404
content-type: text/html; charset=UTF-8
Run the same check for a forbidden directory (expect 403) and confirm there is no 301 or 302 in the chain. Browser developer tools (Network tab) show the same information. Also test on a deep URL to confirm styles and images load, and on mobile to check the page is readable.
Error pages are also a good moment to review the site’s wider health. If a whole domain suddenly returns errors, the cause may be an expired domain or hosting plan rather than a misconfigured page. Tracking renewal dates in TLDix domain monitoring helps you avoid that kind of outage.
Maintenance pages and 503
Planned maintenance needs its own approach. If you temporarily replace the site with a “we’ll be back soon” page that returns 200, search engines may index that page in place of your real content. Return 503 Service Unavailable instead, ideally with a Retry-After header, so crawlers understand the outage is temporary and come back later. Many maintenance plugins do this automatically; check with curl before relying on one. Keep maintenance windows short, because a 503 that lasts for many days can eventually be treated as a longer-term problem.
The same applies to error pages that load slowly or include third-party widgets. An error page should be among the fastest pages on the site, since it is often seen at the moment a visitor is already frustrated.
Design and content tips
- Keep the main navigation and footer so visitors can continue browsing.
- Offer a search box and a short list of your most useful pages.
- Write plainly: “We can’t find that page” works better than technical jargon or jokes that obscure the message.
- Keep 500 pages static and light, without database calls or heavy scripts that might fail for the same reason as the original error.
- Review 404 logs regularly. Frequently requested missing URLs are candidates for a 301 to a relevant replacement page.