location regex

Igor Sysoev igor at sysoev.ru
Tue Nov 1 14:04:35 UTC 2016


On 01 Nov 2016, at 16:44, olat <nginx-forum at forum.nginx.org> wrote:

> Hello,
> 
> I would like to ask about regex. Why these 2 doesn't behave the same?
> 
> location ~ /(apple/|pear/(small|big)/|test(ing|er)/(fruit|vegis)_)*
> 
> location ~ /apple/*|/pear/(small|big)/*|/test(ing|er)/(fruit|vegis)_*
> 
> 
> could you point me to good practice?

The good practice is not to use regex at all.

location /apple/ {
}

locaiton /pear/ {
}

etc.


-- 
Igor Sysoev
http://nginx.com



More information about the nginx mailing list