merge two location site to 1 location

Edho P Arief edhoprima at
Fri Jan 7 17:19:08 MSK 2011

On Fri, Jan 7, 2011 at 9:00 PM, kevinew <nginx-forum at> wrote:
> Now i'll write two sections of location as follow:
> location =/aaa{}
> location =/BBB{}
> But I want to write the two sections to one location?    eg. location
> =/[aaa,BBB]{}  , but it's wrong, and does someone know how to write it?
> Thanks in advance.

if you want it to contain same thing, just create another file and
include that file:

location = /aaa {
  include blah;
location = /bbb {
  include blah;

alternatively someone may have made a tool to batch such job.

Or the slow (and therefore not recommended) way:

location ~ ^/(aaa|bbb)$ {

I had the idea to create a glob-like syntax which expands the
expression automatically upon loading config but as I don't have
enough C skill and apparently there's already tool for that (and
deemed sufficient), it's never got implemented.

More information about the nginx mailing list