In the context of the directories at the server, http://your-domain.com is the root folder. The www part in http://www.your-domain.com is a subdirectory or a subdomain which usually redirects to the root folder. The “www” prefix has no meaning in the way the main Web site is shown. The “www” prefix is simply one choice for a Web site’s host name. It is mostly used because a host name for the web-server is often ‘www’.

If you are using an Apache server to host your site, then the best way to redirect visitors from http://domain.com to http://www.domain.com is by using a .htaccess file.

.htaccess file is the one that has the configuration settings for the particular directory it is placed in. If you are using your hosting provider’s file manager menu then in many cases you may not be able to see the .htaccess file in your root menu. In that case you can download FileZilla, an excellent open-source FTP client. After locating your .htaccess file and downloading it, it is a good idea to make a copy(with original settings) of it first as a backup.

Now to redirect from non-www to www enter the following code in the top of the .htaccess file: (more…)