Reputation: 21
I want to redirect the url for the following scenario in Nginx.
My domain name *.xyz.com
If the user send the request from
reuest url -> abc.xyz.com
abc
is not constant name.
Xyz.com
is my domain and anything before the .xyz.com
is redirecting to xyz.com/<abc>
in the backend
In the backend request goes to
abc.xyz.com
to xyz.com/<abc>
But in the browser Url will be same.
i.e. abc.xyz.com
Upvotes: 2
Views: 451
Reputation: 10304
You could use a regular expression for your server_name and store the subdomain in a named capture. Then have a variable root:
server {
server_name ~^(?<subdomain>.+)\.xyz\.com$;
root /var/www/$subdomain;
}
Upvotes: 1