PHP files being downloaded on condition

Igor Sysoev igor at
Thu Aug 4 10:26:28 UTC 2011

On Thu, Aug 04, 2011 at 04:33:30AM -0400, Samael wrote:
> Thanks for the suggestions, I will check how can I improve my
> configuration upon them. Unfortunately, they seem to be less generic (ie
> including specific paths) and so promote the probability of making
> errors.
> I'm wondering about the regex usage in location though - this is one of
> the things I like very much about nginx. Can you please elaborate the
> reasons for avoiding them?

The difference is how nginx processes location.

If you use only prefix or exact locations, then nginx looks up
the longest match nevertheless of order of locations in configuration file.
This allows you to have hundreds or thousands locations without worrying
how a new location will affect the existant configuration.

Regex locations depend on order, so during adding a new location
you have to look though whole configuration to see if the new location
will affect it.

A man thinks usually that he creates a small configuration with regexes
and it will work always fine. But configuration usually grows eventually
and at some point it become a difficult task to add new locations.

Rewrite rules aggravate this more.

Igor Sysoev

More information about the nginx mailing list