[英]Nginx: How to redirect a location within a location?
我正在尝试将http://test.com/support
或http://test.com/support/
重定向到https://support.test.com
,并且我需要重定向http://test.com/support/*
到https://support.test.com/*
这是我现在拥有的代码,它完成了下半年,但没有上半年……任何想法都将有所帮助。
location /support {
proxy_pass http://support.test.com;
proxy_set_header Host "support.test.com";
proxy_redirect off;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
我认为在位置块中必须有if语句,但我不是100%肯定的。
您是否尝试过将位置更改为这样的正则表达式?
location ~* ^/support(?:/|\z) {
proxy_pass ...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.