Ops runbook · Beginner · 30 min
Custom Error Pages: Honest Status Code, Cheap Render
Your 404 template is a full PHP render for a request that was never going to convert — here is how to make it useful, truthful and cheap, in that order.
The short answer
Return the correct status code first, then decide who renders the page — because a WordPress 404 template costs a full framework bootstrap and several queries, while an Apache ErrorDocument pointing at a static file costs almost nothing.
Most sites get this backwards: they design an elaborate 404 with a hero image and a slider, then discover that automated traffic requesting old URLs is now the most expensive thing the server does all night. Get the code right, keep the page lighter than a real page, and feed the log back into redirects.
By the HostingFast team · Reviewed 12 August 2026
Beginner
Reader level
5
Stages to done
Free
Cost of asking
Proven
Run on live hardware
Thirty minutes covers the whole job: check what you currently return, fix the code if it lies, choose the renderer, and trim the weight. None of it needs a plugin.
The measurements below use curl, and the configuration lives in cPanel's Error Pages tool or in .htaccess. Both are available on every plan here.
What a 404 actually costs to serve
Ask for a URL that does not exist on a WordPress site and the server loads PHP, boots the framework, runs the query that fails to match, resolves the theme, and renders 404.php. That is the same work as a real page, delivered to nobody. Now consider the volume: bots requesting wp-login variants, scanners walking old plugin paths, and years of dead inbound links all land on that template.
Point ErrorDocument 404 at a static HTML file and the same request costs one disk read from NVMe. Measure the difference yourself before you decide it does not matter: curl -o /dev/null -s -w '%{http_code} %{time_starttransfer}\n' https://example.com/no-such-url, run against each option.
The status code is the contract
A missing page must answer 404. A page deliberately removed for good can answer 410, which tells crawlers not to keep asking. What must never happen is a 200 on an error page — the soft 404. It happens most often when a plugin or a well-meaning redirect rule sends every unmatched URL to the homepage, which then reports success. The index fills with URLs that resolve to nothing in particular.
Check it from the command line rather than the browser, because the browser shows you the page and hides the header: curl -sI https://example.com/no-such-url | head -1. If that prints 200, fix it before you touch the design.
What belongs on the page, judged by whether it saves the visit
A search field, links to your four or five best entry points, and one line of plain copy. That is the whole useful payload. Skip the apology, the illustration and the animated 404 numeral: the visitor arrived by accident and is deciding in under a second whether to try again.
The 404 should be the lightest template you own, not the heaviest. Inline its critical CSS, avoid loading the site's full stylesheet and JavaScript bundle for a dead end, and keep any image small enough that the page renders before the visitor's patience does.
Configuring it, and the caching subtlety
cPanel's Error Pages tool writes the ErrorDocument directive for you, per document root, for 400, 401, 403, 404 and 500. Editing .htaccess by hand does the same thing: ErrorDocument 404 /404.html. On WordPress the theme's 404.php takes over instead, and the ErrorDocument only fires for requests that never reach PHP — a missing static asset, for instance.
One caching detail catches people out: do not give error responses a long cache lifetime. A 404 that gets cached for a month keeps serving after you have restored the page, and a 500 cached at the edge turns a two-minute outage into a much longer one. Purge after any change, and leave error responses short-lived or uncached.

Measured on the platform you would be buying
The ErrorDocument behaviour, the cPanel tool and the caching notes above were all exercised on our own stack: the latest cPanel, LiteSpeed in front of NVMe, and .htaccess honoured exactly as Apache documents it.
Every plan includes free SSL that renews itself before it can lapse, so your error pages are served over HTTPS without a certificate to remember.
- Status codes verified with curl, not with a browser tab
- The cost of each rendering option, measured
- cPanel's own Error Pages tool, and the .htaccess equivalent
- Support that will read your access log with you
Why HostingFast
Standard on every plan
Code before cosmetics
The guide fixes what the server reports before it discusses what the page looks like, because only one of those two affects your index.
The soft 404, named and caught
A one-line curl check that tells you whether your unmatched URLs are honestly failing or dishonestly succeeding.
Renderer chosen on cost
PHP template versus static ErrorDocument, with the measurement command so you can see the gap on your own site.
Caching caveat included
Why a long-cached error response outlives the error, and what lifetime to give one instead.
Weight budget for a dead end
The 404 should be your lightest template. The guide says what to strip and what to keep.
The loop back to redirects
Which log to read, and how repeat offenders graduate from a 404 page to a 301.
Quick Start
From order to online
- 1
Find out what you return today
curl -o /dev/null -s -w '%{http_code} %{time_starttransfer}\n' https://example.com/definitely-not-a-page. Note both numbers. The code tells you whether you have a soft 404; the timing tells you what the template costs.
- 2
Correct the code before the copy
If that printed 200, find the culprit: a redirect-everything plugin, a catch-all rewrite, or a theme template that forgets status_header(404). Fix it, re-run the command, and only then think about design.
- 3
Decide who renders it
Static ErrorDocument for the cheap, high-volume case; the theme's 404.php when you genuinely need dynamic content such as personalised suggestions. Many sites are best served by both, with the static file catching requests that never reach PHP.
- 4
Cut the page down to its job
Search box, a handful of real links, one sentence. Inline the critical CSS and drop the site's main bundle from this template. Then measure it: a 404 heavier than your homepage is a fault, not a design choice.
- 5
Turn the repeat offenders into redirects
Pull the 404 list from AWStats and the coverage report in Search Console, then 301 anything with real volume to wherever the content lives now. The error page catches the fall; the redirect is what stops the falling.
Built In
Loaded onto every plan
- The latest cPanel, with its Error Pages tool on every account
- .htaccess honoured as documented, including ErrorDocument directives
- LiteSpeed caching built into the server rather than bolted on by plugin
- NVMe SSD storage on every tier, so a static error page is a fast read
- Free SSL on every plan, renewed automatically before it can expire
- Per-site PHP version switching from the control panel
- Daily backups with self-service restores you run yourself
- Renewal priced at the rate you signed up at, with no setup charge
- Money-back cover: 30 days on hosting plans, 7 on reseller
- Engineers on support at any hour, including the awkward ones
Frequently Asked
What people ask us most often
Should an error response ever be cached?
Briefly at most, and never for long. A cached 404 keeps serving after you have republished the page, and a cached 500 stretches a short outage well past its actual length. Leave error responses uncached or on a very short lifetime, and purge the cache after you change a URL. The one exception worth making is a static ErrorDocument file itself, which is just an asset and can be cached like any other.
Does a heavy 404 template show up in Core Web Vitals?
It can. Field data is collected from real Chrome users on real navigations, and a visitor who lands on your 404 from a stale link is a real navigation. If that template loads the full stylesheet, the JavaScript bundle and a hero image, its LCP counts. A light 404 is one of the few optimisations that costs nothing and helps a number you are being measured on.
When is 410 the better answer than 404?
When the resource is gone deliberately and permanently — a retired product, an expired campaign page, a post you removed on purpose. 404 means not found, which crawlers reasonably re-check for a long time; 410 means gone, and they stop asking sooner. If there is a sensible replacement, though, a 301 to it beats both.
Which error codes deserve their own document?
404 earns real design effort because genuine visitors hit it constantly. 500 earns a plain, dependency-free static file, since the thing that generates a 500 is often the thing that would render a fancy error page. 403 is worth a short explanation when you password-protect directories. The rest can share a generic document without anyone noticing.
Keep reading
How to Schedule Server Backups
Put the backup on a schedule and a retention rule you have actually tested.
How to Create an Email Forwarder
Route an address somewhere else without adding a mailbox to maintain.
404 Error (Glossary)
What the code means, and why returning it honestly matters more than the design.
Drupal Hosting
Drupal on NVMe behind a LiteSpeed cache, with the PHP version under your control.
PHP Hosting
Per-site PHP switching, OPcache and the extensions a real application needs.
Changing hosts? Run through our checklist first.
A straightforward sequence for a switch your visitors never feel: which files move first, how to shift email across without losing a single message, the right moment to repoint DNS, and the two mistakes behind almost all the downtime we get asked to rescue.
Serve the dead ends cheaply too.
LiteSpeed in front of NVMe, .htaccess honoured as documented, per-site PHP switching, and support that will read the log with you at any hour.
View Drupal Hosting plans