W3 Total Cache solution – Resolve www to non-www redirection or vice versa

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...
November 21, 2010

What plugin do you use for caching your WordPress blog. Well the most widely used cache plugin is the WP Super Cache. But with advanced options, the W3 total cache is becoming immensely popular among bloggers. If you are a blogger with a blog setup in wordpress, you should give W3 Total cache a try and I’m sure you’ll love it. But if you have already been using W3 Total cache plugin, you must have noticed that the “www” form of your blog URL doesn’t redirect to the “non-www” form or vice versa.

After installing The W3 Total cache plugin, you’ll find that http://yourdomain.com and http://www.yourdomain.com both open up the homepage of your blog without being redirected to the standard URL chosen for your blog. This can lead to a duplicate content issue. Or in some cases, the “non-www” form redirects to http://yourdomain.com/wp-content/w3tc/pgcache/_default_.html.gzip. This happens because of the modification in your .htaccess file caused by the W3 total cache plugin. Before adding W3 Total cache, your .htaccess file would look something like this:

# 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

But after installing the W3 Total cache plugin, you’ll see plenty of lines added before these within # BEGIN W3 Total Cache and # END W3 Total Cache.

Somewhere the commands in the lines between these opening and closing codes are responsible for hampering www to non-www redirection process. As the lines generated by the plugin appear above the standard code in the .htaccess file, they hold more priority than the general code. So the www and non-www URL issue is caused because of the order of the original lines in the .htaccess file and the lines added to it by the plugin. So, just move the text generated by the plugin way down to the bottom of your .htaccess file and it works. Finally save your .htaccess file and restore it to its respective location.

Now you’ll see that the www form of the URL redirects to the non-www form or vice versa even with the W3 total cache plugin installed.

You may also like...