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

Set up custom error pages

Brand 404 and 500 pages on your shared hosting so visitors stay on your site when a page is missing or something breaks.

Updated

When a visitor hits a missing page or the site cannot serve a request, Apache can show your page instead of a generic browser or server message. Put your logo, a short explanation, and a link home on it so they stay with you.

This article is for Beginner and Standard shared hosting. Open cPanel from the portal. Do not guess a hostname.

On WordPress, most 404 pages come from the theme, not from Apache. Use the Error Pages tool (or .htaccess) for static sites, and for 403 / 500 on any site. The WordPress section below covers the theme 404.

A custom error page is not a domain redirect. A redirect sends the visitor to a different URL. An error page answers on the URL they already typed.

Common HTTP error codes

CodeMeaningWhen visitors see it
400Bad RequestThe request was malformed
401UnauthorizedA password-protected folder needs credentials
403ForbiddenThe server refused the request (permissions, or a denied path)
404Not FoundThat URL does not exist
500Internal Server ErrorThe site could not finish the request
503Service UnavailableThe site is temporarily unable to answer

A 500 is a problem to fix, not only a page to brand. See Fix a 500 Internal Server Error.

Open cPanel

  1. Sign in at the portal.
  2. Open the hosting service for the site.
  3. Click Log in to cPanel.

Use Error Pages (recommended)

cPanel can write the page and the Apache rule for you.

  1. In the Advanced section, open Error Pages.
  2. Choose the domain, addon domain, or subdomain from the menu. Each name has its own document root, so pick the site you mean.
  3. Click the code you want to brand (start with 404). To see extra codes such as 503, use Show All HTTP Error Status Codes.
  4. Type or paste a simple HTML page in the editor. Keep it self-contained: inline styles are fine, do not depend on a PHP layout.
  5. Optional: the tag buttons insert the requested URL, the visitor's browser, and similar. Those tags only expand on the file cPanel saves (usually a .shtml in that site's document root).
  6. Click Save.
  7. Repeat for 403 and 500 if you want those branded too.

Do not delete the .shtml files cPanel creates in that site's document root, or the custom page will vanish.

Or point Apache at your own file

Use this when you already have a static file, or you prefer to keep the HTML in the File Manager.

  1. In Files, open File Manager.
  2. Go to that site's document root: public_html for the main domain, or the addon / subdomain folder.
  3. Create a static file such as error404.html. Put your branding, a clear sentence, and a link to / on it.
  4. Create error403.html and error500.html the same way if you need them.
  5. In File Manager, open Settings and tick Show Hidden Files (dotfiles) so you can see .htaccess.
  6. Edit .htaccess in that document root (create it if it is missing). Add lines like:
ErrorDocument 404 /error404.html
ErrorDocument 403 /error403.html
ErrorDocument 500 /error500.html

The path is from that site's web root, beginning with /. An addon domain that lives in public_html/shop still uses /error404.html if the file is in public_html/shop.

  1. Save the file.

Use either Error Pages or your own ErrorDocument lines for a given code, not both. Two rules for the same code will fight.

A typo in .htaccess can take the whole site to a 500, including the custom error page. If that happens, rename .htaccess in File Manager to restore the site, then fix the line. We also keep hourly backups of the account.

WordPress 404s

WordPress sends almost every missing URL through index.php, then the theme's 404 template. Apache never sees those as a 404, so Error Pages and ErrorDocument 404 will not change what visitors see on pretty permalinks.

  • Edit the theme's 404 template, or the 404 screen in your page builder.
  • Prefer WordPress Toolkit or Installatron for the install itself. See Install WordPress.

Apache custom pages still apply to 403 and 500, and to missing static files that WordPress does not handle. A White Screen or HTTP 500 on WordPress is a different job: Fix the WordPress White Screen of Death / HTTP 500.

What to put on the page

  • Keep it static. Use .html or the .shtml file cPanel writes. Do not use PHP for a 500 page. If PHP is what broke, a PHP error page will fail too.
  • Brand it. Same colours and logo as the live site, so visitors know they did not leave.
  • Say what happened. A 404 should say the page is not here. A 500 should say something went wrong and they can try again shortly. Do not dump a stack trace or a file path.
  • Give a way out. Link to / and, if you have one, your contact or search page.
  • Keep it small. Inline a little CSS. Skip large images and third-party scripts.
  • One message per code. Do not reuse a single "error" page for 404 and 500.

Relative links (/ and /contact) work on both http and https. AutoSSL issues certificates from SSL/TLS Status once the name points at this hosting.

Test

  1. For a 404 on a static site, visit https://yourdomain.com/this-page-does-not-exist-xyz (use the real domain). You should see your page, and the address bar should still show that missing URL.
  2. On WordPress, that same URL tests the theme 404, not the Apache page.
  3. Confirm the page shows your branding and the home link.
  4. Do not try to force a real 500 on a live site to preview the page.

If the custom page does not show

  • Confirm you chose the right domain in Error Pages, and that the HTML file sits in that site's document root.
  • On WordPress, a 404 is the theme. Change the theme template, not only Error Pages.
  • Check .htaccess for a second ErrorDocument line, or a syntax error. See Fix a 500 Internal Server Error.
  • Confirm public DNS for that name still points at this hosting account (Domains → the domain → DNS in the portal).

If the page will not save, the site stays on the default error screen after a valid test URL, or you are unsure which file Apache is serving, open a support ticket and we will check the account with you.

Related


Was this article helpful?

← Back to cPanel