You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Robert Andersson <ro...@profundis.nu> on 2003/11/03 09:10:04 UTC

Re: [users@httpd] Avoid logging errors successfully handled by ErrorDocument

Joshua Slive wrote:
> The contents of the error log are not configurable (except via the
> LogLevel directive).  One possible solution would be to use mod_rewrite
> rather than an ErrorDocument.  See, for example, "Search pages in more
> than one directory":
> http://httpd.apache.org/docs-2.0/misc/rewriteguide.html
> which does something similar.

Yes, that worked. Previously I had something like this:

    ErrorDocument 404 /.../_lib/gallery/img_cachemiss.php?max_width=2048

I now substituted the error document with these lines in an .htaccess:

    RewriteCond %{REQUEST_FILENAME}  !-f
    RewriteRule .* /.../_lib/gallery/img_cachemiss.php?max_width=2048 \
        [env=GALLERY_CACHEMISS:1]

I had a check in that script (img_cachemiss.php), which would only let it
execute if REDIRECT_STATUS was 404. The only way I could ensure it not to be
executed directly was to add a check for that environment variable.

A note here: I was a bit surprised that this worked, because I exploit
multiviews here, so the images are requested without their file extensions.
I'd have thought that the RewriteCond would kick in on a request for eg.
"image" when the existing file is "image.jpeg". It seems as mod_negotiation
do the translation before mod_rewrite does its thing.

However, I will probably use the ErrorDocument variant most of the time, and
survive the occasional 404s in the error log, as it is a simpler and less
error prone

> > On a related note, is there any way to "pass back" an error, eg. File
Not
> > Found, to Apache from a dynamic ErrorDocument? ... Could this be
> > achieved in some way?
>
> Not that I know of.

I didn't think so either. Thanks anyway.

Regards,
Robert Andersson


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org