Reputation: 21585
Is it possible to redirect to the domain from which the request originated within one block?
server {
listen 80;
server_name my.domain.io your.domain.io;
return 301 https://{my.domain.io OR your.domain.io}$request_uri;
}
I know I can create 2 blocks - one referencing my.domain.io
and the other your.domain.io
. My issue is that I have quite a lot of subdomains and don't to repeat the blocks, again and again, introducing lots DRY code.
Is it done using $host
? I am gonna try... but if it's not that let me know. ;)
UPDATE
Nope, $host
is not working...
Upvotes: 2
Views: 62
Reputation: 21585
Thanks to Tarun Lalwani who tested my solution I realized that I didn't have up-to-date code base. So lame from me!
The solution is indeed the $host
:
return 301 https://$host$request_uri;
Upvotes: 2