Title: Supercache .htaccess problem
Last modified: August 19, 2016

---

# Supercache .htaccess problem

 *  Resolved [wahgnube](https://wordpress.org/support/users/wahgnube/)
 * (@wahgnube)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/supercache-htaccess-problem/)
 * I am having some difficulty getting wp-super-cache to work on [my journal](http://emphaticallystatic.org/).
   Briefly:
 * 1. Basic caching is functioning. i.e., I see the message
    `<!-- Cached page served
   by WP-Cache -->` on subsequent reloads of pages.
 * 2. Super-cache pages are being generated. i.e., The folder `/wp-content/cache/
   supercache` exists, and the static HTML files corresponding to pages requested
   previously are being generated. Here is [an example](http://emphaticallystatic.org/wp-content/cache/supercache/emphaticallystatic.org/earlier/good-news-everyone/),
   which contains the comment
    `<!-- super cache -->` at the end of the file.
 * 3. However, my .htaccess file, which contains the line
    `RewriteRule ^(.*) /wp-
   content/cache/supercache/%{HTTP_HOST}/$1/index.html [L]` fails to redirect browsers
   to these Super-cached files. Therefore, all I see when I load pages is the comment
   generated by basic wp-cache.
 * How do I debug .htaccess redirects? Has anyone else experienced this problem 
   and solved it?
 * I am trying this as an arbitrary user (not logged in, no comments, browser cache/
   cookies cleared).

Viewing 12 replies - 1 through 12 (of 12 total)

 *  [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * (@donncha)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/supercache-htaccess-problem/#post-729698)
 * I tried your example link and got a warning about snooping around. Does the problem
   resolve itself if you remove that rewrite rule? I presume there’s a .htaccess
   in wp-content/ ? Remove that and it might work ok.
 *  Thread Starter [wahgnube](https://wordpress.org/support/users/wahgnube/)
 * (@wahgnube)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/supercache-htaccess-problem/#post-729734)
 * Thank you for your help.
 * No, I’m afraid you received the warning because index.html from that folder had
   been cleared (I suppose since that page hadn’t been accessed for some time). 
   I have accessed the page once more (regenerating the cached file), and the link
   works [once more](http://emphaticallystatic.org/wp-content/cache/supercache/emphaticallystatic.org/earlier/good-news-everyone/).
 * I don’t have a .htacess in wp-content. The rule that took you took you to the
   warning exists in / . This rewrite rule that points the browser to the snooping
   warning only kicks in when there isn’t a index document in a directory. And it
   did because the cache had been cleared (because of the appropriate time outs,
   I suppose).
 *  Thread Starter [wahgnube](https://wordpress.org/support/users/wahgnube/)
 * (@wahgnube)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/supercache-htaccess-problem/#post-729768)
 * I believe the problem is that the the following rewrite condition
    `RewriteCond%{
   DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html -f` is 
   not engaging, even though the cached file exists.
 *  Thread Starter [wahgnube](https://wordpress.org/support/users/wahgnube/)
 * (@wahgnube)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/supercache-htaccess-problem/#post-729828)
 * The problem seems to have resolved itself when I replaced the variables DOCUMENT_ROOT
   and HTTP_HOST by their actual values!
 *  [ChrisSamuel](https://wordpress.org/support/users/chrissamuel/)
 * (@chrissamuel)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/supercache-htaccess-problem/#post-729853)
 * OK, because I’m using vhosts in my Apache 2.2 config I found that %{DOCUMENT_ROOT}
   was being set to just /htdocs. So to fix it
    I just needed to prefix it with /
   var/www/%{HTTP_HOST}. You can verify whether or not this is happening for you
   too by looking at the output of the phpinfo() “Server variables” section.
 * My patch was:
 *     ```
       --- .htaccess.hmm       2008-04-06 18:58:17.000000000 +1000
       +++ .htaccess   2008-04-06 20:06:50.000000000 +1000
       @@ -5,12 +5,12 @@
        RewriteCond %{QUERY_STRING} !.*s=.*
        RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$
        RewriteCond %{HTTP:Accept-Encoding} gzip
       -RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz -f
       +RewriteCond /var/www/%{HTTP_HOST}/%{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz -f
        RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz [L]
   
        RewriteCond %{QUERY_STRING} !.*s=.*
        RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$
       -RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html -f
       +RewriteCond /var/www/%{HTTP_HOST}/%{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html -f
        RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html [L]
        </IfModule>
       ```
   
 * Hope that helps!
    Chris
 *  Thread Starter [wahgnube](https://wordpress.org/support/users/wahgnube/)
 * (@wahgnube)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/supercache-htaccess-problem/#post-729861)
 * Thanks for the tip, Chris. I was looking for a way to see the values of HTTP_HOST
   AND DOCUMENT_ROOT.
 * Now here’s the interesting (confusing) thing.
 * According to the output of phpinfo(), both these environment variables appear
   to be set correctly. However (and I just tried this again), replacing the actual
   path by %{DOCUMENT_ROOT} causes the condition to fail.
 *  [ear1grey](https://wordpress.org/support/users/ear1grey/)
 * (@ear1grey)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/supercache-htaccess-problem/#post-729866)
 * I just solved a problem with identical symptoms. The problem _appeared_ to be
   fed by these factors:
    - I have a permalink structure of `/%postname%/`
    - I have wordpress in a [different folder](http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory)
 * The key lines of my rewrites are included below. I have:
    1. added /wp to the start of the path manually
    2. changed the regex replace from $1 to $0
    3. removed from after $0
 * RewriteCond %{DOCUMENT_ROOT}**/wp**/wp-content/cache/supercache/%{HTTP_HOST}/**
   $0index.html.gz** -f
    RewriteRule ^(.*) **/wp**/wp-content/cache/supercache/%{
   HTTP_HOST}/**$0index.html.gz** [L]
 * RewriteCond %{DOCUMENT_ROOT}**/wp**/wp-content/cache/supercache/%{HTTP_HOST}/**
   $0index.html** -f
    RewriteRule ^(.*) **/wp**/wp-content/cache/supercache/%{HTTP_HOST}/**
   $0index.html** [L]
 *  Thread Starter [wahgnube](https://wordpress.org/support/users/wahgnube/)
 * (@wahgnube)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/supercache-htaccess-problem/#post-729889)
 * I see.
 * I assumed `$1` held the match within the first parenthesis in the RewriteRule
   regexp. What does `$0` hold?
 *  [lenary](https://wordpress.org/support/users/lenary/)
 * (@lenary)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/supercache-htaccess-problem/#post-729891)
 * yeah, i’m having problems too – using wordpress-mu
    the wordpress is in `var/
   www/blogs` because we only serve one domain from the server. below is the code
   in the .htaccess
 * >  # BEGIN WordPress
   > RewriteEngine On
   >  RewriteBase /blogs/ 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}/blogs/wp-content/cache/supercache/%{
   > HTTP_HOST}/blogs/$1index.html.gz -f RewriteRule ^(.*) /blogs/wp-content/cache/
   > supercache/%{HTTP_HOST}/blogs/$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}/blogs/wp-content/cache/supercache/%{
   > HTTP_HOST}/blogs/$1index.html -f RewriteRule ^(.*) /blogs/wp-content/cache/
   > supercache/%{HTTP_HOST}/blogs/$1index.html [L]
   > # END WordPress
 * i can only see the front page. no more
    i tried to put `/var/www/blogs` instead
   of `/var/www/%{HTTP_HOST}` but that didn’t help. what should i do?
 *  [lenary](https://wordpress.org/support/users/lenary/)
 * (@lenary)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/supercache-htaccess-problem/#post-729892)
 * ok, properly installed it using above method, but it still doesn’t work
    mod 
   mimes enabled, mod rewrite enabled, and fancy permalinks already used put the
   folder in wp-content/mu-plugins as opposed to wp-content/plugins i now have no
   clue what is going wrong, but i do know that it isnt working, and that it’s not
   telling me why should i have put it in both directories?
 *  [beernews](https://wordpress.org/support/users/beernews/)
 * (@beernews)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/supercache-htaccess-problem/#post-729994)
 * > I tried your example link and got a warning about snooping around. Does the
   > problem resolve itself if you remove that rewrite rule? I presume there’s a.
   > htaccess in wp-content/ ? Remove that and it might work ok.
 * Is there a way to block parent directory access for images, etc. **and still 
   have supercache work successfully**? I created an .htaccess file in wp-content
   with this code from blogsecurity which, of course, made supercache stop working:
 *     ```
       Order Allow,Deny
       Deny from all
       <Files ~ ".(css|jpe?g|png|gif|js)$">
       Allow from all
       </Files>
       ```
   
 *  [beernews](https://wordpress.org/support/users/beernews/)
 * (@beernews)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/supercache-htaccess-problem/#post-729995)
 * Saw that something like this would work…
 *     ```
       <Files "wp-cache-phase2.php"
       Allow from all
       </Files>
       ```
   
 * If I want to allow multiple files, would this be correct syntax?
 *     ```
       <Files "wp-cache-phase2.php,wp-cache-phase1.php,wp-cache-config-sample.php,wp-cache-base.php,searchengine.php,wp-cache-config.php,advanced-cache.php">
       Allow from all
       </Files>
       ```
   
 * Not sure if I would need to include directories as well but I imagine so.

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘Supercache .htaccess problem’ is closed to new replies.

 * 12 replies
 * 6 participants
 * Last reply from: [beernews](https://wordpress.org/support/users/beernews/)
 * Last activity: [18 years, 1 month ago](https://wordpress.org/support/topic/supercache-htaccess-problem/#post-729995)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
