Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

lookahead regex in nginx location

I'm trying to match /category/anything, except /category/paid in nginx location.

I have the following regex, but it's not working. Google tells me that I can use lookahead in nginx. Am I doing something wrong?

location ^/category(?!/paid)/ {

}
like image 379
Moon Avatar asked Sep 04 '13 01:09

Moon


1 Answers

You either need a slash before it or an escaped slash.

location ~ (category/(?!paid)) { .. }
location ~ (category\/(?!paid)) { .. }
like image 144
hwnd Avatar answered Oct 03 '22 10:10

hwnd