Making Awstats ignore the ‘www’ on a domain

awstats is my favorite web statistics program. It provides quite a bit of interesting data about my websites, and I usually set it up for any site that I work on. One issue that I’ve had with it though, is that in a shared setup, by default, it uses the HTTP HOST header to check which domain to display statistics for. The config files and data files are all saved with the full hostname of the domain for the stats it contains. So it treats “www.brandonchecketts.com” different from “brandonchecketts.com”.

This has always been just a slight annoyance to me, and I have just remembered to make sure to put the ‘www’ on the URL when I’m looking at my statistics. Today, though, I thought I would dig into it a little bit to fix it permanently.

Turns out it was pretty easy to change this behavior so that it always just removes the ‘www’ from the domain name for any of the files it looks for. Simply add this on line 1160 of awstats.pl:

$SiteConfig =~ s/^www\\.//g;

It should go right after the $FileConfig= line, and right before the foreach loop. Since all of my database files were created with the ‘www’ in them, I had to go through and rename all of those database files to remove the www from them. Now I can hit either URL and get the same data.

I started a forum thread on the SourceForge forums to announce it to others and see if anybody else finds it useful.

2 thoughts on “Making Awstats ignore the ‘www’ on a domain”

  1. What is the log size provided by Awstats, I am using GoStats.com , they provide a log size of 1000 visitors , I have not found any tool with a bigger log size.

  2. Awstats reads the server generated log files that are created on the web server. They grow as big as you configure them on the server and you keep them for as long as you want. Usually logrotate is used to keep them to a reasonable size.

    From what I can tell gostats is some kind of third party service that collects the statistics, probably by adding a hidden image or javascript on your page. They operate completely differently, so you are limited to whatever they provide.

Leave a Reply

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