I would like to be able to log when a RewriteRule is executed. For example, say I have something like:
Re开发者_JS百科writeCond %{QUERY_STRING} do=Action [NC]
RewriteRule ^/app/(.*)$ ${server:master}/code/base/path/App.php?$1 [P,L]
RewriteRule ^(.*)$ ${server:cache}/other/path/App.php$1 [P,L]
I would like to log the request urls that get rewritten by Rule 1 (on the master server).
Any idea on how to achieve this?
Thanks a huge lot!
You can use the [E] flag to set an environment variable. Then, in your log configuration on the server check for the same environment variable.
So, if you have the following RewriteRule
:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/newurl/
RewriteRule (.*) /newurl/$1 [R,E=rewrite:true]
You can setup a log accordingly:
CustomLog logs/rewrite-check.log common env=rewrite
Hope that helps.
精彩评论