404 Not Found
状态码 404
Not Found
代表客户端错误,指的是服务器端无法找到所请求的资源。返回该响应的链接通常称为坏链(broken link)或死链(dead link),它们会导向链接出错处理(link rot)页面。
404 状态码并不能说明请求的资源是临时还是永久丢失。如果服务器知道该资源是永久丢失,那么应该返回 410
(Gone) 而不是 404 。
状态
404 Not Found
自定义错误页面
许多网站会将 404 页面的外观进行定制,使其对用户更友好,以及提供一些引导。例如,Apache 服务器可以在 .htaccess
文件中进行配置,代码片段如下:
ErrorDocument 404 /notfound.html
你可以访问一下 MDN 的 404 页面获取一些启发。
自定义的404页面应该是对用户友好且可读性高的,不能使用户产生困惑。
规范
Specification | Title |
---|---|
RFC 7231, section 6.5.4: 404 Not Found | Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content |
浏览器兼容性
BCD tables only load in the browser
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.