gpt4 book ai didi

nginx - 如何让nginx停止处理其他规则并服务于特定位置?

转载 作者:行者123 更新时间:2023-12-02 17:35:52 25 4
gpt4 key购买 nike

我的配置在空的 server { } 定义中按预期工作

location ^~ /foo/ {
alias /var/www/foo/;
}

但是当我将其移动到一个相当大的服务器定义(一个用于 WordPress 多站点配置)中时,它将停止工作,并且 wordpress 将响应它(这显然不是我的意图)。

我尝试将其放在服务器 block 的开头或结尾,但这并没有改变它。

如何强制 Nginx 使用此位置?

最佳答案

您可能正在寻找break

location ^~ /foo/ {
alias /var/www/foo/;
break;
}

来自HttpRewriteModule documentation :

last - completes processing of current rewrite directives and restarts the process (including rewriting) with a search for a match on the URI from all available locations.

break - completes processing of current rewrite directives and non-rewrite processing continues within the current location block only.

Note that outside location blocks, last and break are effectively the same.

关于nginx - 如何让nginx停止处理其他规则并服务于特定位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10699755/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com