Our nginx config serves multiple sites with their own subdomains.
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name ~^(?P<sub>.+)\.(example1|example2)\.com$;
root /var/www/instances/$sub;
...
}
I want to redirect one specific subdomain with its path to different sites, but I cannot figure out how to write the check. I need to check for the host part and then check for the path to decide where the redirect should land.
The map looks somehting like this:
| Old URI | New URI |
|---|---|
sub1.example1.com/wiki/0/$path |
newSub1.example1.com/wiki/0/$path |
sub1.example1.com/wiki/20/$path |
newSub2.example1.com/wiki/0/$path |
Where $path is simply the rest of the request URI
All other requests to sub1.example1.com should work as before.