I have the following hostname structure:
main.domain.com
is the main subdomain and is static; any other subdomain is dynamic *.domain.com
The root directory is the same for all hostnames.
Now what happens: When I access fruit.domain.com
its redirecting me to
main.domain.com
, but it should actually stay on fruit.domain.com
.
My configs:
server {
listen 80;
listen [::]:80;
server_name main.domain.com *.domain.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 default_server ssl spdy;
server_name main.domain.com *.domain.com;
root /home/www/app
...
}
Try
$host
[docs] in place of$server_name
.