Question

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)/ {

}
Was it helpful?

Solution

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

location ~ (category/(?!paid)) { .. }
location ~ (category\/(?!paid)) { .. }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top