How do I force the "www" to show up in a domain name?

Our servers are configured so that your domain name will work with or without the 'www' part being included in the URL (eg. http://example.com/ and http://www.example.com/ will both work), so that you don't lose traffic. There are various reasons why you may want your website visitors to see or not see the "www" in the URL; it is a personal choice.   

NOTE: Most third party software such as Wordpress will automatically edit the .htaccess file to do this for you, and editing the .htaccess file may cause conflicts. Contact our support team if you're unsure.

  

Force users to use http://www.example.com 

To force website visitors to use the "www" in your URL, all you have to do is add the following code to your .htaccess file (just replace yoursite.com with your domain name).


# Redirect non-www urls to www
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

  

Alternatively you can use:

# Redirect non-www urls to www
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

 

Force users to use http://example.com 

To force website visitors to drop the "www" in your URL, all you have to do is add the following code to your .htaccess file (just replace example.com with your domain name).


# Redirect www urls to non-www
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule (.*) http://example.com/$1 [R=301,L]

  

Alternatively you can use:

# Redirect www urls to non-www
RewriteEngine on
RewriteCond %{HTTP_HOST} !^example\.com
RewriteRule (.*) http://example.com/$1 [R=301,L]

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How do I use the File Manager?

Our File Manager offers an easy interface to manage your website files and folders. A web hosting...

How much disk space is my site using?

This interface displays information about how you use your account's disk space, and all of your...

Can I host more than one website on my account?

Only some web hosting packages allow you to host multiple unique web sites on one cPanel account...

Does email disk space count towards your total account disk space?

Email (@example.com) disk space does count towards your total hosting account disk space, if any...

How do I perform a trace route?

A trace route, also called tracepath or tracert, is a network tool used to determine the "path"...