Webalizer + .htaccess?

Hey peeps,

I want to require a login in order to few webalizer stats. I know I can probably do this via .htaccess or .htpasswd (haven’t done those in a while, but hey). Just want to know if anyone is aware of a way to do it through the cpanel without handcoding the solution.


That’s not a problem…just go to the Control Panel–>Goodies–>.htaccess / webdav section and follow the directions. :wink:


Hey, thanks. Of course, now my problem is that when I enable that, it seems to clobber webalizer.

I’m using Wordpress with the ComicPress theme. Webalizer is in the ~//webalizer directory of my account. When I do the password protect for that directory, suddenly browsing to that URL (http:///webalizer) gives me a “page not found” within a frame of my Wordpress frontpage. Removing the .htaccess/.ntpasswd file eliminates the problem, so seems pretty cut and dry.

I did notice that the actual URL I use for webalizer is http:///webalizer not http://www./webalizer, which is what the tool is trying to set a .htaccess for (and seems to be what it has for the string in the .htaccess), which suggests to me that I might have to do it by hand in order to get the exact right behavior I’m looking for (since the system owns the file and I can’t edit it by hand, it seems).

Any ideas?

That is the result of the .htaccess file contents that wordpress uses. The default .htaccess rules included in the .htaccess file for WordPress produces that error for pages that are not part of the WordPress installation. Your new “http://www./webalizer, or http:///webalizer (makes no difference if you have the domains set to use “both” www and without www), is *unknown” to Wordpress.

This is probably true, though you should be able to edit the .htaccess file without any problem (Your user should own that file). What you need to do it “combine” the lines in the .htaccess file that allow the password protection with the lines that handle the WordPress re-write rules and modify those re-write rules in order to allow the server to display http:///webalizer. A good guide to doing this to display http://www./stats (which is the default DH stats package, Analog) can be found in the Dreamhost WIki article on making stats available with .htaccess. While the examples use other programs and the “stats” directory, the concept is the same for webalizer and WordPress - just study those examples and modify your .htaccess file accordingly.

Similar, and additional information, with other examples can be found in the Dreamhost wiki article on Mod_rewrite. Just take a look at these two articles, you .htaccess file(s) and make the required adjustments; you should be good to go. Good Luck!



Okay, so I’m gonna document this for folks that might need it later.

What I did was in ~// there is an .htaccess for wordpress

what I did was add this block to that .htaccess (copying the original to .htaccess_orig first, of course):

#BEGIN webalizer

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/webalizer/(.)$ [OR]
RewriteCond %{REQUEST_URI} ^/failed_auth.html$
RewriteRule ^.
$ - [L]

#END webalizer

I confirmed that this corrected the problem with the www./webalizer not working.

Then I went to the ~//webalizer directory and created another .htaccess using the instructions pointed to by rlparker at http://wiki.dreamhost.com/index.php/Making_stats_accessible_with_htaccess

AuthName "Dialog prompt"
AuthType Basic
AuthUserFile /home//.htpasswd
Require valid-user

Then did:

htpasswd -c /home//.htpasswd <stats_username_I_made_up>

it then asks for a new password and confirms the new password

going to the webalizer page then prompts for a username and password, and properly authenticates that user/pass I just created

Seems to work like a charm now, thanks!

Good deal! I’m glad you got it working, and I think it is great you reported back what worked for you so that others can benefit from your experience.

One note:

Your process is much the same as I would have done, but it might help others who are a little more afraid of the command line (shell) to know that the last .htaccess file you built (and the creation of the user/pass combination) can also be done from the Control Panel (Goodies–>Htaccess/WebDAV). All that is needed is to specify the “~//webalizer directory”, and complete the prompts.

The trick to it all is the first .htaccess change you made to allow the http://domain.tld/webalizer directory to be served in spite of the WordPress re-write rules. :wink:


As an update to this I’ve also managed to make awstats work with Wordpress using .htaccess using the same method by changing the above to:

#BEGIN awstats

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/awstats/(.)$ [OR]
RewriteCond %{REQUEST_URI} ^/failed_auth.html$
RewriteRule ^.
$ - [L]

#END awstats


I don’t think I put this in the previous post, but this block must come first in the .htaccess that Wordpress creates. Otherwise you’ll still get the 404 error when trying to get to the stats page. This applies to the Webalizer config from the previous post as well.

I used the following pages to get my awstats installation working keen (tho for some reason the cron job doesn’t run right, so I update the stats when I log in once a day, no biggie):


(much closer install to the second, but the first is useful for reference)