301 redirect WWW to non WWW (.htaccess)

In some cases you’ll want to make sure and re-direct all usage of WWW to you non WWW web address. This will also consolidate your homepage link juice to make sure that only 1 url is getting credit rather than 2. The formal term for this is “URL canonicalization”

01- Open your .htaccess file in notepad

02- paste in the following code at the top of the document (replace yoursite.com with your own site address)

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

03– save and overwrite your previous file (in root)

Note: you’ll also want to add the additional 301 redirects for the following reasons:

A site can have up to 4 variations. Though what that means is that your link popularity could also be divided between these variations.

Assuming your site address is http://yoursite.com, you”ll want to have the other 4 variations redirected to http://yoursite.com

Those other variations could be:

(Now its important to note this level of scrutiny should only be limited to your home page)
(you should also write your code depending on how your end desired URL should look)

Now to further the above code, I also suggest adding the following to and END RESULT like this:

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

redirect 301 /index.html http://yoursite.com/
redirect 301 /index.htm http://yoursite.com/

Note: This process requires an Apache server – which is a default for many websites. though still check with your ISP provider.


– Use this method to consolidate SEO credit from 2 potential URLS into 1.
– Must have a .htaccess file in your root for this to work
– All WordPress installs have a .htaccess in root
– .htaccess file is usually hidden in your FTP client – you might have to turn on “hidden dot files”

301 redirect WWW to non WWW (.htaccess)

Related Posts Plugin for WordPress, Blogger...