Web development

Return a real 404 for a missing page

A missing page should normally return HTTP status 404, even when its body contains a friendly custom error design. A page that looks missing but returns 200 can mislead clients and crawlers.

Worked example

Worked reference example

HTTP/1.1 404 Not Found
Content-Type: text/html; charset=utf-8

<main><h1>Page not found</h1><p><a href="/articles/">Browse available guides</a></p></main>

How it works

The status line communicates the result to software, while the body helps a person recover. Configure the host’s missing-page behavior so the custom body retains the error status. This differs from redirecting every unknown path to the homepage.

Limits and mistakes

The snippet shows an HTTP response, not a complete server configuration. Static hosts have different fallback settings. A single-page application may intentionally route some paths, but unknown content URLs still need a deliberate response policy.

Check the result

Request an invented path and inspect the network status. Confirm it is 404 and the body gives a useful way back without pretending the missing article exists.

Sources

Reference documentation for the behavior used in this guide: