Home > apache > How to trace .htaccess’ RewriteRule

How to trace .htaccess’ RewriteRule

Recently I’ve have had to debug the RewriteRules of my .htaccess (using Apache 2.2.20 version).

For me, the easisest way I’ve found to debug the RewriteRule is to edit /etc/apache2/sites-available/default and add this lines:


RewriteLog "/var/log/apache2/rewrite.log"
 RewriteLogLevel 2

This lines can also be added to apache2.conf.

Now I can adjust RewriteLogLevel from 0 (no log) to 9 (logs almost everything). Don’t forget to read the Apache 2.2 documentation, as this may affect the server’s performance. To disable the rewrite log, adjust RewriteLogLevel to 0 instead of redirecting the RewriteLog to /dev/null, as the log is still created.

In my case, setting the RewriteLogLevel to 2 is enough to debug the rewrite rules, with this command:


tail -f /var/log/apache2/rewrite.log | grep rewrite

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: