Tutorial: Redirecting non-WWW to WWW
I have seen a lot of clients get frustrated quickly after I tell them to set up a 301 Permanent Redirect from the non-WWW version of their website to the WWW version.
Example: Redirect http://domainname.com to http://www.domainname.com
It is important to note that this method only applies to servers running Apache. Be very careful when you change the .htaccess file because it can cause your entire site to fail with a simple typo. I recommend hiring an experienced web designer to do this for you.
First: open your .htaccess file. It should be in the root folder of your website (usually www). If it doesn’t exist, create a new file named .htaccess – that is the entire file name, so don’t add a .txt extension or add anything in front of the period.
Add the following lines (if there are already some code in the file, add these lines above them):
RewriteEngine onRewriteCond %{HTTP_HOST} ^domainname\.comRewriteRule (.*) http://www.domainname.com/$1 [R=301,L]
REMEMBER: Be extremely careful, and make sure you know what you are doing. Depending on the structure of your website, adding these lines in the wrong place can break your website.
I am working on a large post explaining what the .htaccess file is and now to use 301 Permanent Redirects for many reasons – I will publish it as soon as possible.




