How to debug Apache RewriteRule or mod_rewrite

in apache, mod_rewrite

It’s hard to debug Apache RewriteRule (mod_rewrite) problems, especially when you have multiple rules. With applications like WPMU, it can be especially tough because WPMU may likely be doing it’s own RewriteRules.

One trick is to turn on the rewrite log. To turn it on,try these lines in your .htaccess or virtual host file:

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

If you are putting it into your virtual host file, don’t forget to reload it for your change to take effect:

$ sudo /etc/init.d/apache2 reload

And if you are using this in production, don’t forget to turn it off when you are done!

For more info, see the Apache mod_rewrite Docs:

Comments on this entry are closed.

Previous post:

Next post: