How do I redirect www to non-www or vice versa (http and https)?

To do this, simply create a .htaccess file in the public_html folder on your account (if it does not already exist), and add the following line to it (if it isn't already there)

RewriteEngine On

The next step is to add the redirect function to .htaccess. Depending on what you wish to do, below are some copy and paste examples that should work. Simply replace your_domain.com with the domain name you wish to use the code for.

To redirect non-www to www

RewriteCond %{HTTP_HOST} ^your_domain.com$
RewriteRule ^(.*)$ http://www.your_domain.com/$1 [R=301]

To redirect www to non-www

RewriteCond %{HTTP_HOST} ^www.your_domain.com$
RewriteRule ^(.*)$ http://your_domain.com/$1 [R=301]

To redirect non-www to www (while using SSL)

RewriteCond %{HTTP_HOST} ^your_domain.com$
RewriteCond %{SERVER_PORT} ^443
RewriteRule ^(.*)$ https://www.your_domain.com/$1 [R=301]

To redirect www to non-www (while using SSL)

RewriteCond %{HTTP_HOST} ^www.your_domain.com$
RewriteCond %{SERVER_PORT} ^443
RewriteRule ^(.*)$ https://your_domain.com/$1 [R=301]

The last 2 are meant for online stores using SSL or to prevent any SSL errors while using SSL on some pages.

  • 22 Users Found This Useful
Was this answer helpful?

Related Articles

What is domain pointing?

Domain pointing takes domain parking another step further by allowing multiple domains which...

What is domain parking?

Domain parking (at least in the context as it's used here) refers to the process of adding...

What are domain pointers?

A domain pointer is when you have us setup a 2nd domain of yours to point to a subdirectory of...

Why can't I create subdomains?

If your domain is not pointing to our nameservers and is still in the process of being...

Where should I register my domain name?

We can handle domain registrations for you, however you are always welcome to use others...