Cannot access stats because of WordPress

wordpress

#1

Hi all, I’d like help with using the Analog stats (provided by DH) when I am using WordPress. I have already followed these instructions:

http://wiki.dreamhost.com/index.php/Making_stats_accessible_with_htaccess

And they didn’t help. My site still thinks I am trying to access a WP page called “stats” which I am not.

Help would be great, thanks!

PS: I also have domain.com AND www.domain.com redirecting to journal.domain.com if that helps you.


#2

If your .htaccess file looks like this:

[quote]# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php

END WordPress[/quote]

And you make it look like this:

[quote]# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/stats/(.)$ [OR]
RewriteCond %{REQUEST_URI} ^/failed_auth.html$
RewriteRule ^.
$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php

END WordPress[/quote]

That will work. Note that the bold lines have to be added right where they are. If you add them after the WP stuff, it won’t work.


:stuck_out_tongue: Save up to $96 at Dreamhost with ALMOST97 promo code (I get $1).
Or save $97 with THEFULL97.


#3

Hmm, I just tried that, and it’s still thinking I want a blog page called stats. Here’s the relevant part of my .htaccess:

[code] # BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/stats/(.)$ [OR]
RewriteCond %{REQUEST_URI} ^/failed_auth.html$
RewriteRule ^.
$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

END WordPress[/code]Any further ideas? I wouldn’t mind creating a WP page called “stats” and having it redirect somewhere, but http://journal.domain.com/stats/main.html doesn’t work either, so I’m not sure what to do.

I do notice an errant [L] in the version I have, so I tried taking it out - no change.


#4

There are only two things I can think of as possibilities:

  1. Have you refreshed? Make sure you clear your browser’s cache. I have found that on occasion in spite of clearing my cache, I have had to close my browser, and re-start it to cleanly get the “new” page.

  2. Are you sure you put the .htaccess file in the correct directory? It should go in the “base” directory of your wordpress installation.

Other than that, what you have done looks like it is correct, and has worked for me everytime - in a lot of WordPress installations.

–rlparker


#5

Hah! I just opened up IE (rather than clearing my Firefox cache or closing it) and I was able to get to my stats this time. So evidently it’s a cache issue. I’m good now, thanks!


#6

Good Deal! I first noticed the caching issue with the installation of Firefox 2 (which I use almost exclusively), and that was where I found I actually had to clear the cache and close the browser in order to completely clear the cache. I’m glad you got it sorted.

–rlparker


#7

Hmm, apparently WP reset my .htaccess or something. I had to re-insert those lines. It was fine after that, but I wonder if there’s a way to make it permanent, so WP won’t mess with it?


#8

I have not dug into the WP code thoroughly enough to know exactly how it works, but indications seem to be that when WP needs to modify .htaccess, it just “rewrites” it using the “new” rewrite rules, rather than doing any kind of “smart” append or anything.

Things like changing your permalink structure (which rewrites the “rewrite” rules) and, of course, updates to WP seem to be the principle times this happens, though there may be other situations that I have not encountered. :wink:

That said, what I have done is just keep my “original/working” WP .htaccess available so that I can easily “merge” it with the “new” version if WP rewrites it. I have not really considered it a problem as it happens infrequently.

–rlparker


#9

Did you change any settings in WP, or do anything that could have triggered it?

I’m not sure what you could change to keep WP from touching it, so I’d just add it for now and see how it goes.

If you change or add anything, you should check it right after you do, just to see if you can narrow it down to when it happens.


:stuck_out_tongue: Save up to $96 at Dreamhost with ALMOST97 promo code (I get $1).
Or save $97 with THEFULL97.


#10

I have not dug into the WP code thoroughly enough to know exactly how it works, but indications seem to be that when WP needs to modify .htaccess, it just “rewrites” it using the “new” rewrite rules, rather than doing any kind of “smart” append or anything.

Things like changing your permalink structure (which rewrites the “rewrite” rules) and, of course, updates to WP seem to be the principle times this happens, though there may be other situations that I have not encountered.

That said, what I have done is just keep my “original/working” WP .htaccess available so that I can easily “merge” it with the “new” version if WP rewrites it. I have not really considered it a problem as it happens infrequently.

–rlparker

(Weird - I originally posted this, in this thread, hours ago at 1754 PST, but in response to another user’s (or sock puppet’s) post. that is no longer here. I can get to this post’s “original”. but it doesn’t show up anywhere in the “threaded view” though it does show up in the “flat” view and in searches (but not the individual Forum summary screens :open_mouth: . If this is a “repeat” for you, I apologize - I just wanted the OP to see the answer so I “re-posted”


#11

I think if you separate out your own rewrite rules from the WP rules, WP will leave yours alone. ie:

Your own rules

RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} ^/directoryname1/(.*)$ [OR] RewriteCond %{REQUEST_URI} ^/directoryname2/(.*)$ [OR] RewriteCond %{REQUEST_URI} ^/failed_auth.html$ RewriteRule ^.*$ - [L] # End of your own rules

BEGIN WordPress

RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # END WordPress

#12

That’s a great tip! Have you tested it to see if it works that way in WordPress? If so, that is definitely a “keeper” (and probably a good candidate for wiki inclusion) :slight_smile:

–rlparker


#13

Well, I can’t say I’ve tested it properly, but it hasn’t broken so far. When I was researching this, I came across this page:

http://codex.wordpress.org/Using_Permalinks

in which they say “WordPress will play nice with an existing .htaccess and will not delete your existing rules”.

I’m guessing this is only true if you add rules outside of the the WP rule entries (ie before the BEGIN Wordpress comments). I’m also guessing that WP has the right to add and delete anything within the “BEGIN” and “END wordpress” rules.


#14

Good Deal! I definitely think the WP codex is “authoritative”. Thanks for pointing that out; I’m sure it will be helpful to a lot of us. :slight_smile:

–rlparker