SEO Tip: How to Create a Domain Name Redirect with .htaccess and WordPress
In an effort to improve my own SEO understanding, I came across this article at SEO Company on domain name redirects that explains how to set your website to automatically load in www.domain.com form rather than domain.com. This might sound like a minute detail in the grand world of SEO, but believe it or not, this simple improvement really affects how Google and other search engines index your site. Apparently, when your website loads in either www.domain.com or domain.com format, it’s like having two sets of URLs for all of your pages. This means that Google would have to work twice as hard to index all of your content - and we wouldn’t want to put Google through that much trouble.
Here is a quick breakdown on how to setup this redirect when using a WordPress blog:
1) Open your .htaccess file
2) Erase anything that wordpress might have put there - believe it or not it’s useless
3) Paste the following code in the .htaccess file (but be sure to change the code to your domain)
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
4) Save the file and you are golden!!