How to redirect www to main domain – Apache and Nginx Stack

You can setup the direction from www to the main domain by following the step by step below:

all websites in cloudstick

Then click File manager.

File manager in CloudStick

Now, you have to click on the file name .htaccess to edit and add the code below:

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

www redirection htaccess code

Then it is time to add CNAME for www for your domain in your DNS provider, If you have integrated CloudFlare on CloudStick, you can go to main dashboard page of CloudStick, then click on DNS and then you can manage the CloudFlare DNS for any of your domains.

CloudFlare DNS management

Then click on the domain name and add CNAME record as you see in the screenshot below:

Next step is to attach the www to the website. If you have added www already then you can skip this step. For this click on Total Websites and click on the website name.

all websites in cloudstick

Now, click on Domains names and add www.domain.com and click on Attach Domains.

If you have already installed SSL without adding WWW. Highly recommended to remove SSL and install SSL once again.