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 -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -