W3 Total Cache : Page Cache URL rewriting is not working

After migrated to a new server, the W3 Total Cache plugin is not working, no cache page or min file redirect, and display following error messages at the W3tc admin page:

It appears Page Cache URL rewriting is not working. If using apache, verify that the server configuration allows .htaccess or if using nginx verify all configuration files are included in the configuration.

It appears Minify URL rewriting is not working. If using apache, verify that the server configuration allows .htaccess or if using nginx verify all configuration files are included in the configuration.

Environment :

  1. WordPress 3.4.1
  2. W3 Total Cache 0.9.2.4

1 .htaccess Permission

Most cases are caused by file permission of “.htaccess“, find this file at the root of your web directory.

The recommended permission is 644 – chmod 644 .htaccess


-rw-r--r--  1 mkyong mkyong   9988 Aug 23 06:51 .htaccess

If 644 is not working, change it to 664 – chmod 664 .htaccess


-rw-r--r--  1 mkyong mkyong   9988 Aug 23 06:51 .htaccess
Note
Make sure you apply the permission on following directory as well.


./wp-content/w3tc/min/.htaccess 
./wp-content/w3tc/pgcache/.htaccess

P.S Read this Unix File Permission

2. Is Apache support .htaccess?

Check your Apache configuration file – httpd.conf, make sure AllowOverride All is applied on your directory. For example,

File : httpd.conf


<Directory "/your/web/directory">
    AllowOverride All
    Options None
    Order allow,deny
    Allow from all
</Directory>

In short, AllowOverride All supports “.htaccess“, AllowOverride None doesn’t support “.htaccess“.

Note
If you don’t know whether your Apache support .htaccess, ask help from your hosting provider.

3. Invalid .htaccess File

May be you messed up the existing “.htaccess” fine, by accidentally. Try delete the existing “.htaccess” file (remember backup), create a new “.htaccess” and let WordPress and W3tc plugin to write the rules again.

Or you can download my “.htaccess” file, and compare with yours.

Download my-htaccess.zip (12kb)

4. Sequence of Rules

The w3tc plugin is working properly, but above “Page Cache URL or Minify URL rewriting is not working” error message is display on admin page?

The above problem is caused by the sequence of the rules appear in “.htaccess“, make sure WordPress’s rule is appear AFTER the w3tc rules.

.htaccess – Correct!


# BEGIN W3TC Page Cache core
#...
# 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

.htaccess – Wrong!


# 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

# BEGIN W3TC Page Cache core
#...
# END W3TC Page Cache core

References

  1. Apache htaccess
  2. Page Cache URL rewriting is not working
  3. W3 Total Cache “Page Cache URL rewriting is not working..” error

About the Author

author image
mkyong
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider make a donation to these charities.

Comments

Leave a Reply

avatar
newest oldest most voted
Anson
Guest
Anson

Where to change the permission and how do we do it?

Alessandro
Guest
Alessandro

Yeah!!! Great man!!!
My sequence of rules as broken.. problem solved!!

Tnx 4 u help

yong
Guest
yong

it worked ,really thanks!

# 4 Sequence of Rules

Smily Myra
Guest
Smily Myra

Following redirect is working on my local server but not working on live server

RewriteEngine on
RewriteRule ^([A-Za-z0-9-]+)/?$ category.php?cname=$1
RewriteRule ^[A-Za-z0-9-]+/([A-Za-z0-9-]+)/?$ subCategory.php?scname=$1
RewriteRule ^[A-Za-z0-9-]+/[A-Za-z0-9-]+/([A-Za-z0-9-]+)/?$ productDetails.php?pname=$1

David Radovanovic
Guest
David Radovanovic

@mkyong – very helpful article. Every time I’d purge caches the Page Cache Rewriting error would appear. My .htaccess file was a mess. Thanks for sharing. Now if I could every get CDN working life will be fabulous.

trackback
W3 Total Cache???????????? | ?????

[…] W3 Total Cache : Page Cache URL Rewriting Is Not Working http://www.mkyong.com/blog/w3-total-cache-page-cache-url-rewriting-is-not-working/ […]

chi
Guest
chi

Thank you for the post, You saved my time.

Dagi Cueppers
Guest
Dagi Cueppers

Hi Mykong:

Just wanted to thank you for writing this article. I was lost completely, went through your list of suggestions and re-ordering the .htaccess file did the trick.

Thanks so much for saving my Saturday!!!
~Dagi

youri
Guest
youri

Hey thnx for the post! I can’t seem to fix my problem. I’ve tried changing permissions and the sequence of rules in the main .htaccess seems to work just fine. However I still recieve the same error message!

In my installation there seem to be no .htaccess files in the w3tc min and pgcache folder. If I put them there they have dissapeared after updating the plugin. Could this be part of the problem?

Derek Clark
Guest
Derek Clark

Very happy to find this post. I knew the .htaccess file was being read so I was pretty stumped; issue #4 was the culprit. Good post.

Kumar Gauraw
Guest
Kumar Gauraw
Hi, I recently moved from GoDaddy to InMotion Hosting company and everything is going great except that it started to give this error about the Page Cache URL rewrite. I have checked everything, permissions are fine, .htaccess is all as it should be ( Compared with yours and find nothing that I can change in mine). Yet the problem doesn’t seem to go away. The only different thing about my website is, I have configured CloudFlare and MaxCDN both with my W3 Total Cache and disabled Minify feature from W3 Total Cache since it was causing trouble for some of… Read more »
Kumar Gauraw
Guest
Kumar Gauraw

I will be curious to know if you can provide some insight…

MrFrank
Guest
MrFrank

I need to and?
/wp-content/w3tc/min/

and
/wp-content/w3tc/pgcache/

Niclas
Guest
Niclas

Hi!

I’m trying to solve this problem …
in my ./wp-content/w3tc/pgcache/ dir there is no .htaccess file.

I failed to open your htaccess zip.

Thank you.

N

Lauren
Guest
Lauren

Thank you so much! This fixed my issue – I realized there were two of these (one above the W3 Total Cache) – removed the second one and it fixed my error! I’ve been looking for an answer for a few days now and you solved it. :) Happy dance!
# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress