How to make nginx to stop processing other rules and serve a specific location?
nginx
Solution
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.
Problem
I have this config that works as expected in an empty `server { }` definition ``` location ^~ /foo/ { alias /var/www/foo/; } ``` But when I move this in a considerably bigger server definition (one used for a WordPress multi-site config), it will stop working and wordpress will respond to it (which obviously was not my intent). I tried to put at the begining or end of server block, but this didn't change it. How can I force Nginx to use this location?