Skip to content

404 不找到

快速摘要

page or resource 你 requested doesn't exist at 那个 URL — path 是错误, file 是移除, or route isn't 配置.

为什么发生

  • Typo in URL path

  • page or file 是删除 or moved 不使用 redirect

  • route 是不 配置 on 服务器 or in 框架

最小示例

✗ 错误代码
fetch("/api/usrs")  // typo: should be "users"
✓ 修复代码
fetch("/api/users")

URL path 有 typo (usrs 相反的 用户) — 服务器返回 404 因为否 route matches /api/usrs.

如何诊断

  • 检查 URL spelling in 浏览器地址 bar or 请求

  • 验证 route exists in 你的 routing 配置

  • 检查服务器 logs for 404 and 确认 requested path

如何修复

  • 正确 URL 到正确 path

  • 添加 redirect 从旧 URL 到新 one

  • 创建 missing page or 配置 route

如何预防

  • 设置 redirects 当 moving or renaming pages

  • 测试内部链接 regularly and use sitemap checker

相关资源

相关术语

相关课程

  • HTTP

    学习关于 HTTP 状态 codes

  • URL

相关练习

相关工具

← 返回语言