Support » Plugin: W3 Total Cache » [Plugin: W3 Total Cache] non-www to www redirects not working

  • Resolved Mike Davis



    I am using W3 Total Cache with WordPress 2.9.2 and just noticed that when i go to the non-www URL of my site (, it no longer redirects to the “www” version of my site ( The redirect worked fine before installing W3 Total Cache.

    I noticed in another help thread that someone put the following code at the top of their .htaccess file to resolve this issue:

    ‘RewriteCond %{HTTP_HOST} ^$ [NC]
    RewriteRule ^(.*)$$1 [R=301,L]’

    Is this the right way to handle the redirect no longer working? Is there another way to do this that I am missing?


Viewing 2 replies - 1 through 2 (of 2 total)
  • Nevermind. After extensive searching I found out how to do it.

    This order of rules within your .htaccess file is VERY important. Use the following structure when listing your rules (which means the rewrite rules go above the W3TC rules):

    Custom Rules

    W3TC Rules

    WordPress Rules

    Also, you have to use the correct rewrite code within .htaccess. The following is what I use for our MediaTemple hosting, per the MediaTemple knowledgebase. I tried another suggestion and got into a 301 redirect loop, so I went with what MediaTemple told me (funny how that works)! Note: replace “example” with your URL. Note2: I put the rewrite code within an <IfModule> as shown below per a suggestion from Frederick in another post. Not sure if this is necessary, but it seems to work, so I am leaving it.

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
    RewriteRule ^(.*)$$1 [L,R=301]

    Thanks, that helped me out too 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: W3 Total Cache] non-www to www redirects not working’ is closed to new replies.