Roll your own Apache Rewrite log! Rocking your own rewrite log is super-helpful for testing .htaccess rewrite rules, WordPress permalinks, etc. For more information, check the source.
Rewrite log via http.conf
Twist one up via the Apache configuration file by placing this code at the foot of your http.conf (remember to edit the path):
# Roll your own Rewrite log
# Log details via scale of 1 to 9
# 1 = few details, 5 = enough details, 9 = too much detail
RewriteEngine On
RewriteLog "/absolute/path/to/your/wwwroot/public_html/rewrite.log"
RewriteLogLevel 5
via htaccess
..doesn’t work.
Example
Here is an example indicating the type of data logged by the RewriteLog directive:
64.246.32.000 - [07/July/2007:07:07:07 - 0700] [example.com/sid#80077333][rid#800b7a33/initial] (2) init rewrite engine with requested uri /press/wp-comments-post.php
64.246.32.000 - [07/July/2007:07:07:07 - 0700] [example.com/sid#80077333][rid#800b7a33/initial] (2) rewrite /press/wp-comments-post.php -> http://64.246.32.000/
64.246.32.000 - [07/July/2007:07:07:07 - 0700] [example.com/sid#80077333][rid#800b7a33/initial] (2) explicitly forcing redirect with http://64.246.32.000/
64.246.32.000 - [07/July/2007:07:07:07 - 0700] [example.com/sid#80077333][rid#800b7a33/initial] (1) escaping http://64.246.32.000/ for redirect
64.246.32.000 - [07/July/2007:07:07:07 - 0700] [example.com/sid#80077333][rid#800b7a33/initial] (1) redirect to http://64.246.32.000/ [REDIRECT/301]
7 Responses
jc – April 30, 2008 •
Don’t know which version of apache you use, but apache 2.2 does not allow rewritelog in .htaccess files.
Perishable – April 30, 2008 •
Still using Apache 1.3.41 on a shared host, and hopefully will continue to do so for a long time — don’t know what I’d do without direct control over my Apache rewrite logs. Interesting indeed.. I wonder why Apache decided to make the change. Security or performance? In any case, I certainly appreciate you bringing this to my attention. I will update the article with a note explaining this information. Thank you, jc!
Aldo – February 1, 2009 •
Finally, I’ve found the reason of the server error 500! LOL! Thanks jc!
@Jeff
I love your site! Thank you for creating it! ;)
Jeff Starr – February 1, 2009 •
My pleasure, Aldo! Thanks for the feedback! :)
R Foreman – November 13, 2010 •
RewriteLog only works at the server level, outside any directory constructs or .htaccess files.
Tihomir Ipotaliev – December 22, 2010 •
How to do rewrite log file on local host (Windows)?
Andrew – November 4, 2011 •
I’d just like to say that RewriteLog should NEVER be used in a .htaccess file as it will throw an error 500. Keep it to your vhosts rather..