404

Not Found

Official Substatus codes
The web server could not find the requested resource

General explanation of the 404 status code

With the 404 Not Found status code, the server could not find a resource at the specified URL. This message is the most well-known error message even among non-technical users, since even large websites have rigid link structures and a 404 Not Found error message is thrown more often than not.

Specification of the HTTP status code 404

The 404 Not Found status code indicates that the origin server has not found a current representation for the target resource or is unwilling to disclose the existence of one. A 404 Not Found status code does not indicate whether this missing representation is temporary or permanent; the 410 (Gone) status code is preferred over 404 Not Found if the origin server knows, presumably by some configurable means, that the condition is likely to be permanent. A 404 Not Found response is cacheable by default, i.e., unless the method definition or explicit cache controls indicate otherwise (see Section 4.2.2 of [RFC7234]).

Source / Quote by: The 404 Not Found HTTP Status Code is specified by section 6.5.4. of RFC7231.

How to throw a 404 statuscode with PHP?

To throw the HTTP status code 404 on a web page, the PHP function http_response_code can be used. The syntax is as follows: http_response_code(404) (PHP 5 >= 5.4.0, PHP 7, PHP 8)

Test the 404 HTTP status code

In order to be able to display the HTTP status code (in this case 404 Not Found) and other information on the client side, the development console must be opened with F12. Afterwards you have to navigate to the tab "Network". Now you can open the page, in the network tab you should see the web page (example index.php). This must be selected and then the Herder section must be selected. Here the user will see the following result:

Status code 404 Not Found
Overview
URL: https://http-statuscode.com/errorCodeExample.php?code=404
Status: 404 Not Found
Those: Network
IP address: XX.XX.XX.XX
Status code 404 Not Found

How do I solve the problem with the 404 status code?

The 404 Not Found status code can occur for various reasons. Some are trivial, yet others are a bit more complex. The most likely reason is that the URL was misspelled or a link to an internal page was set incorrectly. Another possibility is that the linked page has been deleted from the web server and no follow-up status code such as 410 (Gone) has been set.

But there can also be a slightly more complicated error pattern. If it is ensured that neither the URL is misspelled nor the resource has been deleted, a redirect from the "htaccess" file may also be incorrect. Faulty redirects can often be detected with web tools.

As a last likely possibility, a caching problem can also be considered. Either the problem has already been solved on the server side, but the cache of your browser does not reload the page, but from local memory, or even the web server does not load the latest version. Here, both client-side and server-side the cache should be absolutely cleared.

.

How to create a custom error page for the 404 status code

Creating your own 404 Not Found error page is relatively easy with the web server "Apache" as well as with the web server "NGINX".

Apache Webserver

The web server "Apache" is one of the most popular web servers on the Internet. To create an own 404 Not Found error page in "Apache", the following change must be made in the following file.

File: .htaccess
ErrorDocument 404 /errors/404.html

NGINX Webserver

Similar to the web server "Apache", "NGINX" is also widely used on the Internet. To create your own 404 Not Found error page in "NGINX", the following change must be made in the following file.

File: sites-enabled/default
error_page 404 /404.html;
location = /404.html {
    root /usr/share/nginx/html;
    internal;
}

Browser compatibility of the 404 status code

Chrome Yes
Edge Yes
Firefox Yes
Opera Yes
Safari Yes
Chrome Android Yes
Firefox for Android Yes
Opera Android Yes
Safari on iOS Yes
Internet Yes
WebView Android Yes

What SEO impact does the 404 status code have?

In the world of search engine optimization (SEO), the 404 Not Found "Not Found" status code is more than just a simple error message. It has real and tangible effects on the way search engines perceive and evaluate a website.

When a user or search engine crawler tries to access a page that is not there and thus returns a 404 Not Found error, search engines interpret this as a non-existent page. A sporadic 404 Not Found error here and there will not necessarily have a drastic impact on search engine rankings. However, a cluster of such errors can signal to search engines that the site is not well maintained or updated.

A frequent occurrence of 404 Not Found errors can be perceived by search engines as an indicator of poor site structure or maintenance. This, in turn, can negatively impact the trust that the search engine has in the website. And in the world of SEO, trust is everything. A website that search engines trust tends to rank better in search results.

Also, as previously mentioned, every website has a crawl budget. This refers to the number of pages a search engine crawler will visit in a given amount of time. Too many 404 Not Found errors can result in a significant portion of that budget being wasted on non-existent pages. This means that new or updated content may take longer to be discovered and indexed by search engines.

Another important issue is the loss of backlinks due to 404 Not Found errors. Backlinks are a critical ranking factor, and if an external page links to a URL that returns a 404 Not Found error, that link will no longer be considered a positive ranking factor by search engines.

In summary, 404 Not Found errors, while they may seem harmless on the surface, can have a serious impact on a website's search engine rankings. It is therefore in a webmaster's best interest to regularly monitor and fix these errors to ensure that the website maintains its best possible position in search results.

.

Constants in programming languages

HttpStatusCode.NotFound
http.StatusNotFound
response::HTTP_NOT_FOUND
httplib.NOT_FOUND
http.client.NOT_FOUND
http.HTTPStatus.NOT_FOUND
:not_found

Example of "Client request" and "Server response" for HTTP status code 404

Client request:

GET /missingpage.php HTTP/1.1
Host: www.http-statuscode.com

Server response:

HTTP/1.1 404 Not Found
Content-Type: text/html

<html>
<head><title>404 Not Found</title></head>
<body>
<h1>Not Found</h1>
<p>The requested URL /missingpage.php was not found on this server.</p>
</body>
</html>

Sub status codes of the 404 status code

Sub status codes are purely technical, and should never be sent to the user. For example, if status code 404.1 is thrown, it may be logged, but status code 404 will be sent to the user.:
404.0 Not found
HTTP IIS, Unofficial
404.1 Site Not Found
HTTP IIS, Unofficial
404.2 ISAPI or CGI restriction.
HTTP IIS, Unofficial
404.3 MIME type restriction.
HTTP IIS, Unofficial
404.4 No handler configured
HTTP IIS, Unofficial
404.5 Denied by request filtering configuration
HTTP IIS, Unofficial
404.6 Verb denied
HTTP IIS, Unofficial
404.7 File extension denied
HTTP IIS, Unofficial
404.8 Hidden namespace
HTTP IIS, Unofficial
404.9 Files attribute hidden
HTTP IIS, Unofficial
404.10 Request header too long
HTTP IIS, Unofficial
404.11 Request contains double escape sequence
HTTP IIS, Unofficial
404.12 Request contains high-bit characters
HTTP IIS, Unofficial
404.13 Content length too large
HTTP IIS, Unofficial
404.14 Request URL too long
HTTP IIS, Unofficial
404.15 Query string too long
HTTP IIS, Unofficial
404.16 DAV request sent to the static file handler
HTTP IIS, Unofficial
404.17 Dynamic content mapped to the static file handler
HTTP IIS, Unofficial
404.18 Querystring sequence denied
HTTP IIS, Unofficial
404.19 Denied by filtering rule
HTP IIS, Unofficial
404.20 Too Many URL Segments
HTTP IIS, Unofficial
404.501 Too many requests from the same client IP; Dynamic IP Restriction Concurrent request rate limit reached
HTTP IIS, Unofficial
404.502 Too many requests from the same client IP; Dynamic IP Restriction Maximum request rate limit reached
HTTP IIS, Unofficial
404.503 the IP address is included in the Deny list of IP Restriction
HTTP ISS, Unofficial
404.504 the host name is included in the Deny list of IP Restriction
HTTP IIS, Unofficial

Blog Articles

HTTP Status Codes: A Detailed Analysis of the 404 Not Found and 410 Gone Error Messages

HTTP status codes are an essential part of the Hypertext Transfer Protocol (HTTP), which is the basis for communication between web browsers and web servers. They allow the status of an HTTP reques...

SEO and HTTP status codes: A comprehensive analysis

Optimizing a website for search engines (SEO) is a complex undertaking. One of the often overlooked but crucial aspects for a good ranking are HTTP status codes. These small, three-digit codes info...

Author: Tony Brüser
Author: Tony Brüser

Tony Brüser is an enthusiastic web developer with a penchant for HTTP status codes.

LinkedInGitHub