nginx忽略带连字符的位置

p1r*_*1r0 6 nginx

我遇到了nginx"location"指令和正则表达式的问题.

我希望位置匹配以"/ user-profile"开头的网址.

问题是nginx与之不匹配,但是如果我更改配置并尝试使用userprofile(即没有连字符),它就像魅力一样.

我认为存在与regexp相关的问题,但无法理解它.

我目前的配置是:

location ^~ /user-profile {
    proxy_pass http://remotesites;
}
Run Code Online (Sandbox Code Playgroud)

而且我也尝试过:

location ^~ /user\-profile {
    proxy_pass http://remotesites;
}
Run Code Online (Sandbox Code Playgroud)

我感谢你能给我的任何帮助.

谢谢!

use*_*323 5

尝试

location ^~ "/user-profile" {
proxy_pass http://remotesites;
}
Run Code Online (Sandbox Code Playgroud)