Enabling Dreamhost site stats in WordPress
If you have a Dreamhost account and host your WordPress site with them, you may not be able to see your site stats by DH's standard www.yourname.com/stats url. Here's a little guide to getting them to work, as it's not immediately obvious without a bit of digging around.
OK, first things first. The Dreamhost web panel has, under the Status menu, an area called Site Statistics. Click on this and you should be able to see your site(s) listed.
Here you can specify how long to keep the raw logs for (the default is three days), which users have password-protected access, and how detailed the results are. You can play around with all of these by clicking on the spanner icons (unless DH have changed them since this article was written).
In the option headed "# Users w/Access", you can create logins to view your stats and set passwords. To add a new one just change the username, set and confirm a password, and the list will be amended.
Stats and the .htaccess file
I won't go into much detail about what the .htaccess file is for - that's for another article, or another website. But it's worth getting to know what it does.
In short, .htaccess contains a set of commands to set the configuration for a directory and its sub-directories. With an .htaccess file you can password protect areas of your site, block search engines, set the location of your custom 404 page, and so on. There's plenty you can do with it.
If your site doesn't already have an .htaccess file, create one in an application such as the excellent TextPad or TextWrangler. Create a blank document and add the following:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/(stats|failed_auth\.html).*$ [NC]
RewriteRule . - [L]
</IfModule>
You may have to save the file as something.htaccess in order for your operating system to play ball. Once you've done that, though, you can rename it .htaccess and upload to the root of your server. Once it's in place, with the above code appearing before any WordPress-related lines, you should be able to see your stats via www.yoursite.com/stats, and with your previously-set username and password.
And then you're done! As I said before, the DH web panel allows you to change the amount of info displayed in stats, so take a look around and see what works for you.
Tags: .htaccess, dreamhost, wordpress
July 1st, 2008 at 5.45pm
Do I need to add that .htaccess file to the root drive or the /stats/ directory? (not that I have one at the moment!)
July 17th, 2008 at 2.59pm
If you have a standalone WP install you may well have an htaccess file already in your root. Add the lines from the article above to the top of your .htaccess file, above any code that WordPress has automatically added.
If you don't have an htaccess file in your root, make one and upload. It should then work.
There's some good documentation on the DH site: http://wiki.dreamhost.com/index.php/Making_stats_accessible_with_htaccess