One way to optimize your website for search engines is to have everything on one domain. Search engines (as do some user) consider www.domain.com and domain.com to be two separate locations. Sometimes, you can find different content at these locations. To prevent a search engine getting confused and to also increase your pagerank, both of these domain should point to the same location.
You can do this using Mod Rewrite, an extension for Apache. Simply put the following code into you ‘.htaccess’ file on the root of your website to redirect all traffic from domain.com to www.domain.com:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mysite\.com
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=permanent,L]
The above rewrite code also works for subdomains.
Tags: htaccess, Redirection