htaccess does not work for wp super cache plugin

0

I installed the wp super cache plugin for wordpress on the server and it works fine. But I can not figure out why my .htaccess rules do not work for the homepage.

I make rewrite of the requests for the subdomain www to a folder with a installation of wordpress, www / .htaccess:

# www (blog)
RewriteCond %{HTTP_HOST}% ^www\.domain\. [NC]
RewriteCond %{REQUEST_URI} !^/wp_inspiracoes/
RewriteCond %{REQUEST_URI} !^/index\.php/
RewriteCond %{REQUEST_URI} !^/css/
RewriteCond %{REQUEST_URI} !^/js/
RewriteCond %{REQUEST_URI} !^/fonts/
RewriteCond %{REQUEST_URI} !^/img/
RewriteRule ^(.*) /wp_inspiracoes/$1 [L]

# Rewrite all other URLs to index.php/URL (in house app)
RewriteRule .* index.php/$0 [PT]

And in the www / wp_inspiracoes / .htaccess:

RewriteBase /

#full page cache
RewriteCond %{DOCUMENT_ROOT}/wp_inspiracoes/wp-content/cache/supercache/%{SERVER_NAME}/$1index-https.html -f
RewriteRule ^(.*) "/wp_inspiracoes/wp-content/cache/supercache/%{SERVER_NAME}/$1index-https.html" [L]

# BEGIN WordPress
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

These rules work for accesses such as www.domain.com/algum-post/ and www.domain.com/outro-post/ and rewrite the static local files generated by the wp super cache plugin:

.../wp-content/cache/supercache/www.domain.com/index-https.html
.../wp-content/cache/supercache/www.domain.com/algum-post/index-https.html
.../wp-content/cache/supercache/www.domain.com/outro-post/index-https.html

But they do NOT work for access on www.domain.com (homepage), which should do rewrite to ... / supercache / www.domain.com / index-https.html

So I tried some specific rules for homepage in www / wp_inspiracoes / .htaccess (before the general cache rules did not work):

# homepage rules
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{DOCUMENT_ROOT}/wp_inspiracoes/wp-content/cache/supercache/%{SERVER_NAME}/index-https.html -f
RewriteRule ^(.*) "/wp_inspiracoes/wp-content/cache/supercache/%{SERVER_NAME}/index-https.html" [L]

# full page cache here

I tried several rules for home but they also did not work:

# homepage rules
RewriteCond %{DOCUMENT_ROOT}/wp_inspiracoes/wp-content/cache/supercache/%{SERVER_NAME}/index-https.html -f
RewriteRule ^$ "/wp_inspiracoes/wp-content/cache/supercache/%{SERVER_NAME}/index-https.html" [L]

# full page cache here

Even those rules in www / .htaccess (before the rules that rewrite from www to folder wp_inspirations) also did not work

>     RewriteCond %{HTTP_HOST}% ^www\.domain\. [NC]
>     RewriteCond %{REQUEST_URI} ^/$
>     RewriteCond %{DOCUMENT_ROOT}/wp_inspiracoes/wp-content/cache/supercache/%{SERVER_NAME}/index-https.html
> -f
>     RewriteRule ^(.*) "/wp_inspiracoes/wp-content/cache/supercache/%{SERVER_NAME}/index-https.html"
> [L]
>     
>     # www to /wp_inspiracoes rules here

If someone can please help me with these rules, to work for both homepage (/) and pros posts (/ some-post) Duvida_sobre_htacces_SO_en.txtOpen Viewing Duvida_sobre_htacces_SO_en.txt.

    
asked by anonymous 20.01.2016 / 14:58

1 answer

0

First the wordpress code in htacess:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>

Only after this adds your supercache rules:

# INICIO WPSuperCache
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
AddDefaultCharset UTF-8
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/index.html.gz -f
RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/index.html.gz [L]

RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-    postpass_).*$
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/index.html -f
RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/index.html [L]
</IfModule>
# Final WPSuperCache

Rules for adding in / home / **** / public_html / wp-content / cache / .htaccess

# BEGIN supercache
<IfModule mod_mime.c>
  AddEncoding gzip .gz
  AddType text/html .gz
</IfModule>
<IfModule mod_deflate.c>
  SetEnvIfNoCase Request_URI \.gz$ no-gzip
</IfModule>
<IfModule mod_headers.c>
  Header set Cache-Control 'max-age=300, must-revalidate'
</IfModule>
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType text/html A300
</IfModule>
    
21.01.2016 / 03:39