- First thing you have to know (or need to find out) is if your website hosting provider is running a linux server with Apache, and that the Apache Rewrite module has been enabled. This is a definite requirement for this code to work. In most cases your website hosting provider will have this enabled already, and should not have a problem enabling this if it has not been enabled already.
- Download the .htaccess file from your website's root directory (or get it here). To edit your .htaccess file open it up with notepad or a similar program. Be sure to replace mywebsite.com with your own website's domain. You don't have to edit anything else in the file unless you know what you are doing.
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
#REDIRECT NON-WWW TO WWW
RewriteCond %{HTTP_HOST} ^mywebsite\.com [NC]
RewriteRule ^(.*)$ http://www.mywebsite.com/$1 [L,R=301]
Note: (Make sure to escape periods in the RewriteCond line with backslashes. This mostly relates to search-engine friendliness and unity of web stats.) - Upload the file back to your website's ROOT directory. If you have downloaded this file from the root directory on your website, or if you are replacing an existing .htaccess file on your website, always remember to make a backup first of the existing .htaccess file.
- Once the upload is complete, open your web browser and try visiting the "non-www" version of your website address. If the .htaccess is working as it should you will be redirected immediately to the full "www" version of your website. This will be reflected in your browser's address bar.
- If the redirect worked for you, then are done! :)
If this did not work then you need to restore the backup you made of the .htaccess file to your website. After the backup is restored go back and review the revised .htaccess info in the file, compare the information to the instructions above and make sure there were no mistakes. If no mistakes are found your server may require some custom programming which is beyond the scope of this doc; please contact your website hosting provider for more information.

