How to make nginx to stop processing other rules and serve a specific location?

前端 未结 3 1006
情话喂你
情话喂你 2021-01-01 15:45

I have this config that works as expected in an empty server { } definition

location ^~ /foo/ {
    al         


        
3条回答
  •  北荒
    北荒 (楼主)
    2021-01-01 16:36

    You are probably looking for break.

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

    From the 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.

提交回复
热议问题