Balaji
Balaji

Reputation: 869

Rewrite URL in Custom Logs

I have defined a rewrite URL in http.conf to append a parameter to the request URL. In the Custom Log output I am not seeing the modified request URL. When I looked at the cause I found in one of the forums that mod_rewrite only affects accesses invoked via HTTP and does not affect file operations inside the server. Is that true and is there any way to log only the modified rewrite URL in the Apache logs? Your help is much appreciated.

The sample URL I am trying to access is http://www.abc.com/pixel.gif?on=test and in the output I want something like /pixel.gif?type=modified&on=test.

RewriteCond %{HTTP_HOST} www\.abc\.com
RewriteRule ^/(.*)$    /$1?type=modified       [QSA,L]
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

Upvotes: 1

Views: 1038

Answers (1)

summea
summea

Reputation: 7603

There is a way to log rewrite-related things if you turn on the RewriteLog directive.

Basically, you would be adding this to your .htaccess file (and the log path may vary):

RewriteLog "/usr/local/var/apache/logs/rewrite.log"
RewriteLogLevel 5

But note, that RewriteLogLevel can really slow down your development or production server. You might want to use a smaller number... instead of 5. And when you are done checking your RewriteRules... you will most likely want to comment out (or delete,) the RewriteLog/RewriteLogLevel lines.

Hope that helps with your debugging!

Upvotes: 1

Related Questions