I ran into this thread because I wanted to use mod_log_sql with
mod_rewrite. I ran into the exact problem described in this thread.

I managed to fix it by patching libapache2-mod-log-sql and compiling it
myself.

The adjustment is in functions.h:
https://github.com/OutOfOrder/mod_log_sql/blob/1.100/functions.h#L91-L98

In this function, request_rec->status is used, but as described in
http://httpd.apache.org/docs/2.2/developer/API.html#log_handlers:

>When a request has internally redirected, there is the question of what to
log. Apache handles this by bundling the entire chain of redirects into a
list of request_rec structures which are threaded through the r->prev and
r->next pointers. The request_rec which is passed to the logging handlers
in such cases is the one which was originally built for the initial request
from the client; note that the bytes_sent field will only be correct in the
last request in the chain (the one for which a response was actually sent).

This is the root cause of the problem. By checking if request_rec is not
null, and if that's the case, using the next request's status code, the
correct status codes are stored in the database. This solution works for
requests through mod_rewrite as well as requests which are not rewritten.

Best,
Luc van Donkersgoed


On Thu, 12 Sep 2013 20:00:07 +0200 Thomas Mayer <thomas.ma...@slicewise.net>
wrote:
> using up-to-date debian wheezy, the problem still is not solved:
>
> The http response header returns a http status 404:
>
> Date: Thu, 12 Sep 2013 17:52:37 GMT
> Server: Apache/2.2.22 (Debian)
> X-Powered-By: PHP/5.4.4-14+deb7u4
> [...]
> Content-Type: text/html; charset=UTF-8
>
> 404 Not Found
> ===
>
> while mod-log-sql writes this to the database:
>
> select request_uri, status from accesslog where request_uri
> ='/thisdoesnotexist2.html';
> +-------------------------+--------+
> | request_uri             | status |
> +-------------------------+--------+
> | /thisdoesnotexist2.html |    200 |
> +-------------------------+--------+
>
> ----
> http://www.slicewise.net
> http://www.2bis10.de
>
>

Reply via email to