Redirect from non-www to www URL
A very important aspect of search engine optimization is duplicate content. When you have a site.com and a www.site.com you in effect have duplicate content. This isn't quite the issue it used to be but it is still good practive to settle on one or the other- www being the most popular.
So when a user types in trainmejoomla.com we want the address bar in the browser to redirect the user to www.trainmejoomla.com. Doing this is simple. Enter the code below after the Rewrite Engine:on in the .htaccess file on the root of your website directory.
# non-www to www redirect
rewritecond %{http_host} ^yourwebsite.com
rewriterule ^(.*)$ http://www.yourwebsite.com/$1 [r=301,nc]