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 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 :
- WordPress 3.4.1
- 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
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“.
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.
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
Thanks for the great info.
I have a question regarding where to place the SSL rule when forcing a site to load over SSL. Should I place it before or after the W3 Total Cache rules in htaccess?
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
Where to change the permission and how do we do it?
Yeah!!! Great man!!!
My sequence of rules as broken.. problem solved!!
Tnx 4 u help
it worked ,really thanks!
# 4 Sequence of Rules
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
@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.
Thank you for the post, You saved my time.
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
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?
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.
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 my website pages.
Any thoughts?
Regards,
Kumar
Try this for testing.
1. How about the 4. Sequence of Rules?
2. Try disable CloudFlare and MaxCDN.
I tried Rule 4 already and also by disabling CloudFlare and MaxCDN both. The message persists.
However, if I disable Page Caching, the error goes away.
What do you think?
If plugin n wordpress are latest, tried all my solution, still yet to solve your problem, then too bad, try post your question on http://wordpress.org/support/forum/plugins-and-hacks , hope you get answer and tell me how you solve it 🙂 Good luck.
I will be curious to know if you can provide some insight…
I need to and?
/wp-content/w3tc/min/
and
/wp-content/w3tc/pgcache/
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
I zipped as “.htaccess”, it may hidden in your system. In Widows, make sure you are able to see the hidden file. In *nix or Mac, uses “ls -lsa” to display the hidden files.