views:

37

answers:

1

I'm playing around with Apache's mod_rewrite module, and want to know if there is a decent way to output some debugging information? For example, the documentation lists a number of variables available:

%{HTTP_USER_AGENT}, %{HTTP_REFERER}, %{HTTP_COOKIE} ... etc

Is there a way I could output these just to see what I'm working with? I set up the RewriteLog (Level 2) and have been looking at that, but it'd be nice to be able to see the value of the variables.

+1  A: 

The HTTP_ variables come from HTTP headers, so you can print them using server side scripting, as with most of the other variables. For special variables, you can capture their values in a RewriteCond and append that to the query string.

RewriteCond RF=%{REQUEST_FILENAME}&API=%{API_VERSION} (.*)
RewriteRule ... ...?%1 [QSA]

To debug rewrite rules, I've found it helpful to run a virtual host solely for this purpose.

outis