WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] .htaccess HTTP_COOKIE not working (Super Cache problem) (9 posts)

  1. WP Super Cache is working fine with one little problem for me. The "RewriteCond %{HTTP_COOKIE} !^.*wordpressuser.*$" portion does not seem to be engaging.

    When I log into my blog and try to reply to a comment, I do not get the usual "Logged in as..." message. Instead I get the static HTML page out of the cache and I end up removing that page out of the cache to reply as myself.

    Which is odd, my wordpressuser_XXXXXXXXXXX cookie is set and the rewrite condition should prevent me from hitting the static version out of /wp-content/cache/supercache/.

    I'm betting that there is something basic I'm missing, any help would be appreciated. Aside from HTTP_COOKIE not working, my re-write works fine for my permalinks.

    Here is a copy of my .htaccess for reference:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{QUERY_STRING} !.*s=.*
    RewriteCond %{HTTP_COOKIE} !^.*comment_author_.*$
    RewriteCond %{HTTP_COOKIE} !^.*wordpressuser.*$
    RewriteCond %{HTTP_COOKIE} !^.*wp-postpass_.*$
    RewriteCond %{HTTP:Accept-Encoding} gzip
    RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1index.html.gz -f
    RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1index.html.gz [L]
    
    RewriteCond %{QUERY_STRING} !.*s=.*
    RewriteCond %{HTTP_COOKIE} !^.*comment_author_.*$
    RewriteCond %{HTTP_COOKIE} !^.*wordpressuser.*$
    RewriteCond %{HTTP_COOKIE} !^.*wp-postpass_.*$
    RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1index.html -f
    RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1index.html [L]
    <IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    </IfModule>
    # END WordPress

    Nested IfModule put in by plugin.

    Thanks,

    Jan Dembowski

  2. Gah. I think I found what the problem was. I'm using Admin SSL so the cookie that is set for the SSL version of the page.

    Disabling that plugin, clearing my browser cache and cookies seems to fix it. With the cookie set that way then the test works in .htaccess. I'll check but I think that just commenting will always work (vs logging in).

    I'll play with the re-write rules (I'm also trying to see if I can get the re-write rules working for this and Lighttpd) and see if I can get it working.

  3. If you are using the Admin SSL plugin and WP Super Cache then add to your .htaccess this line in the WP Super Cache section:

    RewriteCond %{HTTP_COOKIE} !^.*wordpressloggedin_.*$

    Then when you login using SSL the .htaccess will not serve the static page.

  4. Trent Adams
    Member
    Posted 6 years ago #

    I am having this issue as well and that additional line in the .htaccess didn't seem to help. Any ideas?

    Trent

  5. Donncha O Caoimh
    Member
    Posted 6 years ago #

    Trent - any unusual cookies? Any plugins we should know about?

  6. Trent Adams
    Member
    Posted 6 years ago #

    Nothing unusual donncha. I am running the Haris.tv ssl admin plugin the same as Jan and trying to get it to play nice with the wp-super-cache plugin you wrote. The cache plugin checks to see if the user has commented or is logged in looking for the normal wordpress cookie and the ssl admin plugin encrypts the cookie so it is more secure. Just trying to find a way to get your cache plugin to notice the new cookie.

    Just for reference, I tried Ryan's plugin, but it didn't work for me as it gave me an indefinite loops trying to find the admin area.

    Being more specific, if I turn off super cache and just leave on wp-cache, it works fine. The minute I turn on super cache again it doesn't notice the cookie. Instead, it serves up the super cache page and not the wp-cache page (if super exists) and doesn't read the cookie unless I hit the https same version of the page.

    It really is perplexing and the line Jan references doesn't seem to work for me, but maybe it is about location in the .htaccess? I have other plugins running, but nothing that plays around with the cookies at all. Super Cache works fine before enabling this plugin as well.

    Thanks,

    Trent

  7. Donncha O Caoimh
    Member
    Posted 6 years ago #

    Is the cookie key that plugin generates predicatable? Can you hard code it or a portion of it into the .htaccess rule?
    That RewriteCond should be repeated twice if you're using .gz compression, or once otherwise. It should appear just before the RewriteRule line(s) in .htaccess that serve the super cache files.

    If I had time I'd debug that plugin myself but unfortunately time is something I don't have.

  8. Trent Adams
    Member
    Posted 6 years ago #

    yeah donncha you are a bit busy these days :) Appreciate the comments. I *think* I have it working now with the following:

    RewriteCond %{HTTP_COOKIE} !^.*comment_author_.*$
    RewriteCond %{HTTP_COOKIE} !^.*wordpressuser.*$
    RewriteCond %{HTTP_COOKIE} !^.*wp-postpass_.*$

    The difference being that I used the wordpressuser without the "_" at the end. It seems to be working now.

    Thanks for you time and your help!

    Cheers,

    Trent

  9. askapache
    Member
    Posted 6 years ago #

    This works even better.

    RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$

Topic Closed

This topic has been closed to new replies.

About this Topic