Awstats with Apache and mod_rewrite

I recently setup a new Awstats install and used mod_rewrite to make it easier to view web stats. Using the following configuration within a virtual host declaration, you can simply make requests in the following format:

http://awstats/$CONFIG/$YEAR/$MONTH/$DAY/

This is assuming that you run daily rollups.

  ServerAlias awstats

  RewriteCond %{REQUEST_URI} !^/awstats/awstats.pl [NC]
  RewriteCond %{REQUEST_URI} !^/icon               [NC]
  RewriteRule ^/(.*)/(.*)/(.*)/(.*)/ http://%{HTTP_HOST}/awstats/awstats.pl?databasebreak=day&day=$4&month=$3&year=$2&config=$1 [L,NE]

Leave a Reply

Your email address will not be published. Required fields are marked *