Why should a 404 error page return the correct HTTP status code and not be redirected?

A 404 error page is a manually created error page that is returned when a nonexistent page is requested by a client. Redirecting a page can sometimes lead to user confusion.

Lily Ray on 404 status codes vs 301 redirect

Lily Ray is a member of the SISTRIX data journalism team.

An example: if you request the URL https://www.sistrix.com/I-do-not-exist/, we have no content for that page. As the requested page does not exist and therefore has no content, our web server will show you an error page (also called a 404 page) specifically created for this reason.

404 error page example
When opening the URL https://www.sistrix.com/I-do-not-exist/ the server shows a correct 404 error page complete with HTTP status code

When a user requests a nonexistent URL on your website, you should return an individual error page that lets them know that the requested URL does not exist. You should also make sure that the server returns the correct HTTP status code “404“.

The HTTP status code “404” means “file not found” and is the exact opposite of the HTTP status code “200”, which is “file found.”

What are HTTP status codes for?

The search-engine’s webcrawlers use the HTTP status code to check if the requested URL is available, HTTP status code “200”, or not, HTTP status code “404”.

Why is the HTTP status code 404 important for nonexistent pages?

Only when your server returns the correct status code, can search-engines realise that a URL is no longer available and then remove that URL from the index, after a certain time.

If a 404 page returns the wrong HTTP status code, for example “200”, then the URL can show up in the search results. The result looks like this:

404 error page with wrong HTTP status code – "200" instead of "404"
404 error page with wrong HTTP status code – “200” instead of “404”

Why an automatic redirect is not the best solution

To automatically redirect all incoming links to nonexistent pages to the landing page, by using the HTTP status code “301”, is not the best solution. In this scenario, the user will not get to where they expected to go and, even more importantly, will not know that the content is not available anymore.

Additional information about this topic:

Steve Paine