If you’re using WordPress as your blogging platform, you probably know that it is SEO-friendly and takes care of many things intelligently. One of these is redirecting non-WWW to the WWW version of your website, or vice versa, based on your settings under the “General” tab. By default, WordPress handles this redirection automatically.
However, I recently discovered a bug after updating my blog to the latest version (3.1). The non-WWW version of my site was no longer redirecting to the WWW version, which could have a significant impact on my website’s SEO. After some investigation, I found that the issue was related to my cache plugin, specifically the W3 Total Cache plugin. When caching was enabled, the redirection failed.
After some trial and error, I stumbled upon a thread on the WordPress forum that provided a solution. If you find yourself in the same situation, follow these steps to fix the WordPress redirect bug:
- Move your WordPress redirects above the codes added by W3 Total Cache in your .htaccess file.
Your redirection code will look something like this:
apache
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]
By placing this code above the code added by W3 Total Cache, you ensure that the redirects take precedence.
- Clear your cache. After making the necessary changes, clear your cache to ensure that the new settings take effect. This step is crucial in ensuring that your redirection is happening as expected.
- Check your redirection status. Visit your website to test if the redirection is now working correctly. If everything seems to be fine, you can finally sit back, relax, and enjoy a well-deserved cup of coffee.
Remember, if you’re using the W3 Total Cache plugin (or any other cache plugin), always double-check your redirection status after any updates or changes to ensure that everything is functioning as intended. By following these steps, you can quickly resolve the WordPress redirect bug and maintain a smooth user experience while optimizing your website for search engines.