404 Not Found - HTTP | MDN
View originalCrawl details
- Best
Summary (TL;DR)
This MDN article explains the HTTP 404 Not Found response status code. It shows a typical 404 response with headers like Cache-Control and Content-Type, and a simple HTML error page. It details how to configure a custom 404 page on Apache using an .htaccess file with the ErrorDocument directive, pointing to a file like notfound.html or 404.php. It advises making custom 404 pages humorous and human but not confusing. It also links to related specs and the 410 Gone status code.
Status
http
404 Not Found
Examples
Page not found
Fetching a non-existent page may look like the following request:
http
GET /my-deleted-blog-post HTTP/1.1
Host: example.com
The server returns a response similar to this:
http
HTTP/1.1 404 Not Found
Age: 249970
Cache-Control: max-age=604800
Content-Type: text/html; charset=UTF-8
Date: Fri, 28 Jun 2024 11:40:58 GMT
Expires: Fri, 05 Jul 2024 11:40:58 GMT
Last-Modified: Tue, 25 Jun 2024 14:14:48 GMT
Server: ECAcc (nyd/D13E)
Vary: Accept-Encoding
X-Cache: 404-HIT
Content-Length: 1256
<!doctype html>
<head>
<title>404 not found</title>
...
Custom error page in Apache
For the Apache server, you can specify a path to a custom 404 page in a .htaccess file.
The example below uses notfound.html as a page to show visitors on 404s, although a common approach is to name the file 404.html or 404.php (depending on the server-side technology) at the top-level of the server:
apacheconf
ErrorDocument 404 /notfound.html
Note: Custom 404 page design is a good thing in moderation. Feel free to make your 404 page humorous and human, but don't confuse your visitors as to why they are seeing something unexpected.
For an example of a custom 404 page, see the KonMari 404 page.
Specifications
| Specification |
|---|
| HTTP Semantics # status.404 |
See also
Help improve MDN
Was this page helpful to you?Yes No
This page was last modified on by MDN contributors.