lighttpd server.error-handler-404问题

在使用Lighttpd部署站点的时候,有可能会设置server.error-handler-404来处理404的错误页面。使用Google管理员工具的时候需要对站点进行验证,有两种验证方法,其中一种是在服务器创建一个特殊的文件。但在验证过程上发现了奇怪的错误,提供“我们检测到您的 404(找不到文件)出错页在标头中返回 200(成功)状态”。根据Google的帮助文档这个问题是一个应该是404的页面返回了200的状态码,这听起来怎么这么绕口。。。Google除了验证特殊文件名的文件之外,还会验证404页面是否正常。

在解决这个问题时,发现原来是Lighttpd的Bug,文档如下:

Versions of lighttpd prior to 1.4.17 contained bugs in the implementation of this directive that meant a 404 status code generated from dynamic content was sent to the error handler. This prevented a 404 status code being sent from the error handler itself, which always returned status 200. If you are using an older version, and want to send a 404 status code please use server.errorfile-prefix; however, server.errorfile-prefix does not allow dynamic handlers.

http://redmine.lighttpd.net/projects/lighttpd/wiki/Server.error-handler-404Details

而服务器上的是1.4.13。

分享到: 更多