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

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

  •  
  •   n0th1ng · Jul 7, 2011 · 6595 views
    This topic created in 5430 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
        1
    raptium  
       Jul 7, 2011
    404
    并且不需要跳转吧 如果跳转的话 原来返回的就是 30x 了
    icyflash
        2
    icyflash  
       Jul 7, 2011
    像你说的这种是302了
    jarod
        3
    jarod  
       Jul 7, 2011
    404 在服务器端定义404指向什么页面
    istef
        4
    istef  
       Jul 7, 2011
    先 302,然后再 200 或 404 都有道理,你说的其实是两个页面
    lepture
        5
    lepture  
       Jul 7, 2011
    为什么要跳转?
    icyflash
        6
    icyflash  
       Jul 7, 2011
    要返回什么status code是可以控制的,你需要返回什么就写什么。

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

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

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