Total WordPress Optimization • Search Engine Optimization • WordPress & SEO • WordPress security • PPC • Psychology • WordPress Design • WordPress Installation

Full Version: www redirect to no www
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
To minimize load times (save a DNS lookup) do this

Redirecting www to non www or vice versa.

Redirect from non-www to www

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]


Redirect from www to non-www

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]



Or the HTTPS version:

Redirect from www to non-www

RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]



Redirect from non-www to www

RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]



Use the first if you decided your domain is http://www.yourdomain.com and the second if you decided your domain is http://yourdomain.com

And in WordPress settings set the url according to your decision.

It doesnt matter which yoy choose, but it maters that you make a choice!
Thanks ! I have tried a number of different things but this must be the fastes way to redirect :-)
Thanks for the instructions! Really useful Smile
Thanks for sharing this. I was also looking for a good way to do this. Really useful.