Skip to content

Server-wide custom error pages on cPanel that work for every vhost

How to set a default branded error page across every cPanel account on a host using WHM's Customization tool plus a fallback Include Editor entry, with the precedence rules made explicit.

A reseller wants every account on their server to inherit a branded 404 page unless the customer overrides it. The cPanel-supported tool for this is WHM > Customization > Public Contact Information, plus a Pre VirtualHost Include for ErrorDocument defaults. The combination ends up with a sensible per-vhost fallback: customer’s page if set, server default if not, Apache stock if neither.

What’s happening

Apache evaluates ErrorDocument in nearest-scope order: .htaccess beats per-vhost include, per-vhost include beats global include, global include beats nothing. A server-wide default is set in WHM > Apache Configuration > Include Editor > Pre VirtualHost Include without scoping to a single vhost — it applies to every vhost. cPanel’s customer-level Error Pages tool writes to the user’s .htaccess, which (with proper AllowOverride) overrides the server default. So both can coexist cleanly.

How to verify

Confirm what the current defaults are server-wide:

grep -r "ErrorDocument" /etc/apache2/conf.d/ /etc/apache2/conf/
apachectl -t -D DUMP_INCLUDES | head
curl -sI https://account-without-custom-page.example.com/missing.html | head
ls /usr/local/cpanel/htdocs/

If no ErrorDocument lines exist outside /home/, there is no server-wide default.

The fix

  1. Create the branded error HTML files in a shared location: /var/www/error-pages/404.html, /var/www/error-pages/500.html, /var/www/error-pages/403.html. Make them static HTML — no PHP, no SSI — so they always render even when PHP-FPM is the cause of the error.
  2. Add an alias and ErrorDocument block via WHM > Apache Configuration > Include Editor > Pre VirtualHost Include (do not scope to a specific vhost):
    Alias /error-pages /var/www/error-pages
    <Directory "/var/www/error-pages">
        Require all granted
        Options None
    </Directory>
    ErrorDocument 404 /error-pages/404.html
    ErrorDocument 403 /error-pages/403.html
    ErrorDocument 500 /error-pages/500.html
  3. apachectl -t && apachectl graceful.
  4. Validate by hitting a non-existent URL on an account that does not have its own ErrorDocument: curl -sI https://example.com/this-does-not-exist. The response should be 404 and the body should be your branded page.
  5. On an account that has its own ErrorDocument in .htaccess, the customer’s page should still win. Validate by hitting their domain — confirm the customer’s .htaccess ErrorDocument takes precedence.
  6. Document the precedence chain so the next operator who edits /var/www/error-pages/404.html and wonders why one customer is unaffected can read it.

For environments where every account inherits a baseline experience but can override, Stack Harbor sets the global-with-override pattern during onboarding under managed cPanel operations.