How to add www before subdomain in htaccess

125 Views Asked by At

So, we printed some cards but the card accidentally has www.sub.domain.com/example but when to try to go there it says the site cannot be reached but If we try to go to sub.domain.com/example it works.

The main website is made in WordPress but the landing pages (subdomains) are made using Unbounce can this be fixed using .htaccess? if so then which .htaccess file and how can we fix this.

Thank you

1

There are 1 best solutions below

0
Marius Jaraminas On

You need to redirect your www to non-www. That can be done by adding this to your .htaccess:

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

Don't forget to change yourdomain with your domain.