Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

lighttpd: 404 page does not return 404 status

I'm using a lighttpd 404 error handler, with a static 404 page. The entire conf file looks like this:

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" )
  }
}

However, when I go to an address that should 404, I do correctly see our 404 page, but the status code is 200.

The lighttpd docs say that you should get a 404 status code if using a static page.

I think we're using a static page, but could something about the way we're redirecting mean that we're actually not?

Sorry for the newbie question.

like image 750
Richard Avatar asked Oct 15 '25 09:10

Richard


1 Answers

Fixed this by using server.errorfile-prefix instead - think it is simply a bug in server.error-handler-404.

Seems to be a known bug in some versions of lighttpd. I was actually using a later version than 1.4.17, but still seeing the same problem.

like image 138
Richard Avatar answered Oct 17 '25 15:10

Richard



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!