.htaccess 404 错误页面自定义
404 错误页面是用户最常遇到的错误类型。一个冰冷的、无引导的 404 页面会极大损害用户体验并在 SEO 中产生负面影响。优秀的 404 页面应能引导用户返回正确路径并保持整体视觉的一致性。
通过 .htaccess 定义自定义错误页面非常简单:
ErrorDocument 404 http://www.example.com/404.html
常用错误代码说明:
400 - Bad request (错误的请求)
401 - Authorization Required (需要认证)
403 - Forbidden (禁止访问)
404 - Not Found (无法找到该页)
500 - Internal Server Error (内部服务器错误)
401 - Authorization Required (需要认证)
403 - Forbidden (禁止访问)
404 - Not Found (无法找到该页)
500 - Internal Server Error (内部服务器错误)
按照以上格式添加即可。如果是虚拟主机环境,这通常是实现自定义错误的最佳甚至唯一手段。