How to Add www. to Your Domain Name

You can add www. at the beginning of your domain name and we will demonstrate how to do that in this tutorial.

When you register a domain name and publish your website, initially your website does not have www. part in its domain. Let's say you registered

tutsandtips.com

as your domain. When you publish your website, it will be accessible through

http://tutsandtips.com/

Now, you can continue using that way or modify it so that it will be located at

http://www.tutsandtips.com/

There is no right or wrong way to do this. You can go with either option. However, from the SEO (Search Engine Optimization) point, you should decide on one of them and continue with it for the rest of the life of your website. Simply because http://tutsandtips.com/ and http://www.tutsandtips.com/ are not exactly the same thing from a search engine crawler's perspective, so if people give links to either URL, the other will not benefit from it unless you have proper redirection.

Another important point is that if you are using either one of them without redirecting the other one to the one that you are using, visitors may get an error when trying to access your website. For example, if you are using http://tutsandtips.com/ and you are not redirecting http://www.tutsandtips.com/ to http://tutsandtips.com/, then if a visitor types http://www.tutsandtips.com/ in the address bar, the website will not load and give an error. This is an important thing to keep in mind and you may lose visitors because of this.

In summary, you can choose either option but you should choose it before even publishing your website and stick to it.

Having said that, let's continue with how to add www. to your domain name:

How to Add www. to a Domain Name

1. Go to the root directory of your website. If your domain is a stand-alone domain, its root folder is the public_html folder. If your domain is an addon domain, its root folder is the domain folder that was created when you added your domain to your hosting account.

2. Find the .htaccess file in the root directory. If there is no .htaccess file, you can create it yourself with the File Manager or a text editor (if your server has necessary permissions). Note that the name of the file is exactly .htaccess and it doesn't have another word before the dot.

3. Copy and paste the following code into your .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^tutsandtips.com$ [NC]
RewriteRule ^(.*)$ http://www.tutsandtips.com/$1 [L,R=301]

4. Replace example with your own domain name and then save the file. If you created a new .htaccess file, make sure it is in the root directory of your website.

The above code basically redirects visitors and search engine crawlers to http://www.tutsandtips.com/ if somehow they land on http://tutsandtips.com/. It means, when you type tutsandtips.com in the address bar of your browser, it will automatically redirect to www.tutsandtips.com.

f t g+ in