0

Redirect subdomains to main domain

MonsterCake fa 9 anys updated by janxb fa 9 anys 3
Is there a simple way to redirect all subdomains *.domain.com to domain.com?
in the nginx configuration of your site >> content tab >> custom confiquration
enter youre server_name like this
server_name yourdomain.com *.yourdomain.com;
I tried this solution but it doesn't work for me. Also tried this to no avail:
server {
server_name *.mydomain.com;
rewrite ^(.*) http://mydomain.com$1 permanent;
}
Please, give me some hint!
Please have a look at the answer I posted in this thread.

Edit: You then would add a nginx redirect in the created default host to redirect to the main domain.