regex - What is the best way to handle Nginx rewrite with subdomains? -
i need parse out subdomain , add end of url, example:
subdomain.mysite.com
needs rewrite subdomain.mysite.com/subdomain
subdomain.mysite.com/login
needs rewrite subdomain.mysite.com/subdomain/login
trouble arises because have set of reserve words don't want match, example various different environments.
dev-web.mywebsite.com
should not map mywebsite.com/dev-web
this have far... struggling nginx syntax , regex in general.
if ($host ~ ^([^.]+)\.(.+)) { set $subdomain $1; } if ($subdomain ~* ^(dev-web|uat-web)$) { rewrite ^ $scheme://$host/$subdomain$request_uri permanent; }
the various errors many redirects or not redirecting @ all. err_too_many_redirects
subdomain.mysite.com/subdomain/subdomain/subdomain/subdomain...
Comments
Post a Comment