Exclude Wordpress’ Admin URLs from your AWStats Reports
After upgrading a friend’s blog to Wordpress 2.7 we started noticing his pageview numbers in AWStats going through the roof, without a corresponding increase in visitors. Here’s a screenshot:
Google Analytics was showing normal pageview numbers, so we knew something was amiss. When we looked at the most viewed pages in awstats, it became obvious:
AWStats has always counted pageviews on the Wordpress backend, but compared to the total pageviews the impact was negligible. However, now that Wordpress 2.7 makes so many AJAX calls to admin-ajax.php (primarily for saving drafts), we must exclude these pageviews from our reports to leave meaningful data. Thankfully its very easy.
We’re going to instruct awstats to ignore hits on any page in the wp-admin directory. Alternatively, we could have AWStats ignore our IP address, which has its own merits, but this approach becomes cumbersome when multiple authors and dynamic IPs come into play.
Instructions:
- Open the awstats .conf file which corresponds to your domain. On most shared hosting accounts this will be located in /tmp/awstats/. If you see more than one .conf file, choose the one which matches the domain of the site you are working on.
- Look for the line which starts with:
SkipFiles="
AWStats is usually already configured to exclude robots.txt and favicon.ico, so the line probably looks like this:
SkipFiles="robots.txt$ favicon.ico$"
- Append the following string after the last filename listed (make sure to leave a space), but before the quote:
REGEX[^\/wp-admin\/]
If you’re file looks like mine, the line should now read:
SkipFiles="robots.txt$ favicon.ico$ REGEX[^\/wp-admin\/]"
- Save and upload the file. If you’re on shared hosting, you’ll want to CHMOD the .conf file to 444, otherwise your changes are likely to be overwritten.
That’s it! This change is not retroactive, but if all went well you should be able to write a new post in Wordpress and the pageviews for admin-ajax.php will not increase.

Get a Trackback link
4 Comments
Many thanks for the tip – I’d noticed the ‘internal’ pages turning up when I was doing some mass editing (tags etc.), but never got around to figuring out how to purge them.
Hopefully blindingly obvious to others reading this, but don’t forget that wordpress has helpfully converted some of the quotation marks in the code above, so don’t go randomly copying text from above, and pasting it into your config files
@ChrisM – Really glad this helped you out, thanks for leaving a comment. Its a simple thing to do, but surprisingly hard to find instructions for.
I’ve updated the code in the article to use <pre> tags instead of <code>, and that seems to have thwarted Wordpress’ “smart quotes”, so the code can be copied and pasted again. Thanks for the catch.
George,
I agree, that is a great tip! I’d been looking for “concise” instructions, and yours are great! Thank you for sharing! I’ll be adding this to every one of my Wordpress sites from now on!
Much appreciated!
–matt
George,
I played around with it a little more and changed it to this:
SkipFiles=”robots.txt$ favicon.ico$ /wp-cron.php /wp-login.php /xmlrpc.php REGEX[^\/wp-includes\/] REGEX[^\/wp-admin\/]”
It’s not working perfectly, yet, but the goal is to remove all the extra pages… I think that’s most of them… also, on a side note… I was able to clear the old data simply by renaming the awstats022010.myhostname.net.txt file and Updating the stats. It rebuilt the stats just fine.
Good luck!
Matt
Leave a comment