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

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

python - Error: Unresolved reference 'selenium' What is the reason? -

php - Need to store a large amount of data in session with CI 3 but on storing large data in session it is itself destorying automatically -