Community

how to redirect any subdomain to main domain using .htaccess

fa
faizakbar18 #1

hello,
im new with cyberpanel, im using this for wordpress, i want redirect any sub-domain to main domain with .htaccess, i was try edit rewrite rules and add this code below LSCACHE and before wordpress rules

RewriteCond %{HTTP_HOST} ^(.+)\.mydomain\.com$ [NC]
RewriteRule ^ http://mydomain.com/ [L,R]

but not working, have any solution?

am
amccristovao #3

Hi, maybe this helps:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^webmail.canamhosting.ao$ [OR]
RewriteCond %{HTTP_HOST} ^webmail.canamhosting.ao$
RewriteRule ^(.*)$ https://canamhosting.ao:8090/rainloop/$1 [R=301,L]

Sign in to reply