Skip to content

Custom Apache error pages per cPanel account

How to set custom 403, 404, 500 error pages for a single cPanel account through the cPanel UI and verify the ErrorDocument directives end up in the right vhost include.

A customer wants their own branded 404 page. The cPanel UI for this exists, works, and has worked since the late 2000s — yet operators still occasionally drop ErrorDocument directives into a global include or a hand-edited .htaccess and wonder why the change does not stick. The right path is the cPanel Error Pages tool; the verification is checking that the directive actually landed in the vhost include.

What’s happening

cPanel’s “Error Pages” interface (cPanel > Advanced > Error Pages) writes the customer’s chosen content into HTML files at /home/<user>/public_html/<code>.shtml and adds matching ErrorDocument directives to the user’s .htaccess. For the file to be served on the error code, two things must work: AllowOverride must permit FileInfo (covered in the dedicated AllowOverride article), and the file path in ErrorDocument must be absolute relative to the vhost docroot, not the filesystem.

How to verify

For a given account:

ls -la /home/<user>/public_html/*.shtml
grep -r "ErrorDocument" /home/<user>/public_html/.htaccess
apachectl -t -D DUMP_INCLUDES | grep <user>
curl -sI https://example.com/this-does-not-exist.html | head

The curl should return HTTP/1.1 404 plus the body of the custom page if the directive is wired up correctly.

The fix

  1. From the customer’s cPanel: cPanel > Advanced > Error Pages > pick the error code (404 most commonly) > write or paste HTML > Save. cPanel writes /home/<user>/public_html/404.shtml and updates .htaccess with ErrorDocument 404 /404.shtml.
  2. If the customer cannot or will not log into cPanel, do the same as root: place the HTML file in their docroot with their ownership, then add the directive to their .htaccess (or to a Pre VirtualHost Include you control).
  3. Confirm the ErrorDocument is in effect: curl -sI https://example.com/this-does-not-exist.html returns 404, then curl -s https://example.com/this-does-not-exist.html | head shows the custom page body.
  4. If the directive is in .htaccess but the default error page is served, AllowOverride for the directory is not permitting FileInfo. Either widen the override (per the dedicated article) or move the ErrorDocument to the vhost include.
  5. For accounts where errors should be JSON (an API account), ErrorDocument can point at a PHP script that emits the right headers. Be careful: the error handler is invoked for every error including HEAD requests; do not have it do expensive work.
  6. Server-wide custom error pages are a separate tool — see the companion article. Per-account always wins over server-wide if both are set.

For environments where branded error pages are part of the customer experience, Stack Harbor wires them in during onboarding under cPanel server administration.