Hunter Johnson
Hunter Johnson

Reputation: 11

W3TC Page Cache Url Rewriting is not Working

I am having trouble getting W3tC page cache to work. I checked the rewrite rules and they are all set on my vps server. I recently set up the vps server through Digital Ocean.

The error I am getting is:

W3 Total Cache error: It appears Page Cache URL rewriting is not working. Please verify that the server configuration allows .htaccess Unfortunately disk enhanced page caching will not function without custom rewrite rules. Please ask your server administrator for assistance. Also refer to the install page for the rules for your server.

The technical info is .htaccess file contains rules to rewrite the URL. The plugin made a request to https://example.com/w3tc_rewrite_test but received: 404 Not Found instead of "OK" response.

Upvotes: 1

Views: 5170

Answers (3)

Niroshan
Niroshan

Reputation: 408

This error is caused by the sequence of the rules that appear in “.htaccess“, make sure WordPress’s rule appears AFTER the W3TC rules.

#...
# END W3TC Page Cache core

So

The final .htaccess file structure should be like

# BEGIN W3TC Browser Cache
 
......
 
# END W3TC Browser Cache

# BEGIN WordPress
.....

# END WordPress

This is a tested method and worked well. Thank you.

Source: Fix – W3 Total Cache error: It appears Page Cache URL rewriting is not working – Easy Method

Upvotes: 0

Mohammad nagdawi
Mohammad nagdawi

Reputation: 592

This is a short answer to @h2kyaw one. If you add the following line in .htaccess root directory will enough.

<IfModule mod_rewrite.c>

    RewriteRule ^(.*\/)?w3tc_rewrite_test([0-9]+)/?$ $1?w3tc_rewrite_test=1 [L]

</IfModule>

Upvotes: 0

h2kyaw
h2kyaw

Reputation: 11

Test with those code in your root/.htaccess

# BEGIN W3TC Browser Cache  
 <IfModule mod_rewrite.c>
<IfModule mod_deflate.c>
  <IfModule mod_headers.c>
     Header append Vary User-Agent env=!dont-vary  
   </IfModule>
     AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json  
   <IfModule mod_mime.c>
     # DEFLATE by extension  
     AddOutputFilter DEFLATE js css htm html xml  
   </IfModule>  
 </IfModule>
 # END W3TC Browser Cache  
 # BEGIN W3TC Page Cache core  
 <IfModule mod_rewrite.c>
   RewriteEngine On  
   RewriteBase /  
   RewriteRule ^(.*/)?w3tc_rewrite_test/?$ $1?w3tc_rewrite_test=1 [L]  
   RewriteCond %{HTTP:Accept-Encoding} gzip  
   RewriteRule .* - [E=W3TC_ENC:_gzip]  
   RewriteCond %{HTTP_COOKIE} w3tc_preview [NC]  
   RewriteRule .* - [E=W3TC_PREVIEW:_preview]  
   RewriteCond %{REQUEST_METHOD} !=POST  
   RewriteCond %{QUERY_STRING} =""  
   RewriteCond %{REQUEST_URI} /$  
   RewriteCond %{HTTP_COOKIE} !(comment_author|wp-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC]  
   RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" -f  
   RewriteRule .* "/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" [L]  
 </IfModule>  
 # END W3TC Page Cache core  
 # BEGIN WordPress  
     <IfModule mod_rewrite.c>
         RewriteEngine On  
         RewriteBase /  
         RewriteRule ^index.php$ - [L]  
         RewriteCond %{REQUEST_FILENAME} !-f  
         RewriteCond %{REQUEST_FILENAME} !-d  
         RewriteRule . /index.php [L]  
     </IfModule>
 # END WordPress

Upvotes: 1

Related Questions