4

How to match multiple times in nginx location regex ?

it seems the {x,x} syntax never works!

for example:

location ~ ^/abc/\w{1,3}$ { ... } 

nerver work!

2
  • try ^/abc/\w\w?\w?$ Commented Sep 10, 2014 at 11:22
  • Raj, I know this works, but it seems a little bit ugly... Commented Sep 10, 2014 at 11:23

1 Answer 1

8

You must quote location which contains { or ; characters.

location ~ "^/abc/\w{1,3}$" { ... } 

otherwise nginx parse it as location ~ ^/abc/\w { 1, ... and fails with syntax error.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.