【问题标题】:Setting http status code with php [duplicate]用php设置http状态码[重复]
【发布时间】:2014-01-16 07:22:14
【问题描述】:

使用header() 使用 PHP 设置自定义状态码响应时:

header("Status: 404 Not Found");

正确,或者:

header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found");

http 标准是什么?或者,你应该同时设置吗?

【问题讨论】:

  • 第二个是正确的。据我所知,第一个不是有效的 http 标头,它将是“HTTP/1.0 404 Page Not Found”您几乎可以将其视为“
  • @Justin,您的答案已经在 Gould 发布的链接中。

标签: php http-headers http-status-codes


【解决方案1】:

我通常会设置这样的错误代码:

header('HTTP/1.0 404 Not Found');

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-09-04
    • 2013-05-14
    • 1970-01-01
    • 1970-01-01
    • 2012-07-10
    • 1970-01-01
    • 1970-01-01
    • 2015-04-20
    相关资源
    最近更新 更多