【问题标题】:lighttpd: 404 page does not return 404 statuslighttpd:404 页面不返回 404 状态
【发布时间】:2011-11-22 17:47:03
【问题描述】:

我正在使用带有静态 404 页面的 lighttpd 404 错误处理程序。整个 conf 文件如下所示:

server.document-root = "/home/www/local/www/mysite/html"
url.rewrite = (
  "^(.*)/($|\?.*)" => "$1/index.html",
  "^(.*)/([^.?]+)($|\?.*)$" => "$1/$2.html"
)
server.error-handler-404 = "/404.html"
$HTTP["scheme"] == "http" {
  url.redirect = ( "^/blog.html$" => "/blog/",
       // various individual redirects
  )
}
$HTTP["scheme"] == "https" {
  $HTTP["url"] !~ "^/blog/admin/" {
    url.redirect = ( "^/(.*)" => "http://www.mysite.com/$1" )
  }
}

但是,当我转到一个应该是 404 的地址时,我确实正确地看到了我们的 404 页面,但状态码是 200。

lighttpd docs 说如果使用静态页面,您应该获得 404 状态代码。

我认为我们使用的是静态页面,但我们重定向的方式是否意味着我们实际上不是?

抱歉新手问题。

【问题讨论】:

    标签: webserver http-status-code-404 lighttpd http-status-codes


    【解决方案1】:

    改用server.errorfile-prefix 修复了这个问题 - 认为这只是server.error-handler-404 中的一个错误。

    好像是a known bug in some versions of lighttpd。我实际上使用的是比 1.4.17 更高的版本,但仍然看到同样的问题。

    【讨论】:

    • 谢谢,这解决了我的问题。我也在更新版本,但有同样的问题。虽然我认为我们的服务器位于 nginx 服务器后面,这可能是问题的一部分。记住也要使用文件的完整路径!文档中不清楚的东西。
    猜你喜欢
    • 2020-05-12
    • 2013-08-28
    • 2021-06-09
    • 2014-07-29
    • 1970-01-01
    • 2017-05-23
    • 1970-01-01
    • 2019-11-14
    • 1970-01-01
    相关资源
    最近更新 更多