Why is server.error-handler-404 serving 200 instead of 404?
In lighttpd.conf I ahve
server.error-handler-404 = "/error.htm"
File exists, it is served ok, but the server returns 200 instead of 404 when we request an non existent url.
Please make a fix, because it breaks lots of development tools.
Please not the setting server.errorfile-prefix does not fix the problem.
server.errorfile-prefix = "/wheel/www/www.ejobs.ro/static/status-"
curl -I http://domain.com/nonexistent.html
HTTP/1.1 200 OK
Expires: Fri, 16 Nov 2012 07:36:22 GMT
Last-Modified: Mon, 16 Jan 2006 21:30:01 GMT
Date: Thu, 08 Nov 2012 07:36:22 GMT
Updated by stbuehler over 7 years ago
- Status changed from New to Invalid
- Target version deleted (
Just because it doesn't do what you want it to doesn't mean it is a bug; also changing such behavior in a stable branch would be bad.
The fact that the "bug" title contains a question mark indicates that you should have used the support forum instead.
that said: server.error-handler-404 was intended as a "rewrite-if-file-does-not-exist", so 200 is ok.
also we now recommend to use exactly this:
url.rewrite-if-not-file = (...)
server.errorfile-prefix is provided to change the html that is displayed for errors, not to handle the errors; to not loop in errors only static files are supported for this.
Updated by sdan over 7 years ago
- Status changed from Invalid to Reopened
What I ask is a normal behavior.
We use lighttpd for serving static contents, no mod_rewrite, no mod_fastcgi, light as possible.
Please be more flexible because in the future you will lose lots of users.
Please give us an fix to give error 404 when the url is invalid.
Updated by gstrauss over 4 years ago
server.errorfile-prefix preserves the HTTP error status code when returning a static file error page in the HTTP response.
@sdan, if that is not what you're seeing, then please check your configuration. server.error-handler-404 (if set) takes precedence over server.errorfile-prefix for error codes 403 and 404, so please ensure that server.error-handler-404 is not set in your configuration if you are using server.errorfile-prefix to handle 403 and 404 pages.
stbuehler, https://redmine.lighttpd.net/projects/1/wiki/Server_error-handler-404Details description of server.error-handler-404 includes:
You can use a dynamic or static page for the handler. If you use a static page, the server will return a 404 HTTP status code with the content of your static page.
so it is easy to see how people might be confused when server.error-handler-404 returns 200 OK for static pages from error handler. I have updated the wiki documentation. Would you please take a look and review the change?
Also available in: Atom