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. ie abc.xyz.com
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;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.