• 请不要在回答技术问题时复制粘贴 AI 生成的内容
n0th1ng
V2EX  ›  程序员

资源不存在,跳转到404页,返回http 200 还是 404?

  •  
  •   n0th1ng · Jul 7, 2011 · 6996 views
    This topic created in 5598 days ago, the information mentioned may be changed or developed.
    比如网站 www.fakesite.com, 访问 www.fakesite/fafdsfdsfdsfsd,跳转到www.fakesite/error404, 这时,该返回什么http状态码?200 还是404?
    7 replies  •  1970-01-01 08:00:00 +08:00
    raptium
    raptium
    Jul 7, 2011
    1
    404
    并且不需要跳转吧 如果跳转的话 原来返回的就是 30x 了
    icyflash
    icyflash
    Jul 7, 2011
    2
    像你说的这种是302了
    jarod
    jarod
    Jul 7, 2011
    3
    404 在服务器端定义404指向什么页面
    istef
    istef
    Jul 7, 2011
    4
    先 302,然后再 200 或 404 都有道理,你说的其实是两个页面
    lepture
    lepture
    Jul 7, 2011
    5
    为什么要跳转?
    icyflash
    icyflash
    Jul 7, 2011
    6
    要返回什么status code是可以控制的,你需要返回什么就写什么。

    status code是通知机器/程序的,页面是给人看的。

    如果你需要通知程序,就直接返回status code 404, 程序并不关心你之后跳到哪去。

    给人看的话,就随便了,别人也看不到这个status code。
    chloerei
    chloerei
    Jul 7, 2011
    7
    返回404和渲染404页面,不要跳转
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   5565 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 02:04 · PVG 10:04 · LAX 18:04 · JFK 21:04
    ♥ Do have faith in what you're doing.