Apache2 SetEnvIF

apache-2.2

I must be missing something here

If I use this ruleset:

SetEnvIf Remote_Addr "::1" loopback
SetEnvIf Remote_Addr "127\.0\.0\.1" loopback
CustomLog logs/access_log combined env=!loopback

SetEnvIf Request_URI "^/img/" env=images
CustomLog logs/error_log combined env=!images

I end up with localhost requests in my error_log, which I don't want AND I still have images shown too.

This always gives me an syntax error message, apparently you can't have more than the 'env' variable defined?

SetEnvIf Remote_Addr "::1" loopback
SetEnvIf Remote_Addr "127\.0\.0\.1" loopback
CustomLog logs/access_log combined env=!loopback

SetEnvIf Request_URI "^/img/" images=1
CustomLog logs/error_log combined images=!1

I tried this trick:

SetEnvIf Remote_Addr "::1" loopback
SetEnvIf Remote_Addr "127\.0\.0\.1" loopback
CustomLog logs/access_log combined env=!loopback

SetEnvIf Remote_Addr "::1" images
SetEnvIf Remote_Addr "127\.0\.0\.1" images
SetEnvIf Request_URI "^/img/" images
CustomLog logs/error_log combined env=!images

From here:

http://www.tek-tips.com/viewthread.cfm?qid=276232&page=198

But I still see image requests in my logs.

Does anyone have any other methods I could use to filter failed (or even all) image requests of this type?

File does not exist: ..../public_html/agility/img/4thjuly/earth.png,

Best Answer

Request_URI "^/img/" means that the URI begins with img, so the request /public_html/agility/img/4thjuly/earth.png still be logged. Try this:

SetEnvIf Request_URI "(.*)/img/*" images
CustomLog logs/error_log combined env=!images