Nginx Location Regex Tester

Nginx chooses a location by a fixed order, not by position in the file. Getting the modifiers wrong is the most common reason a rule silently does not apply.

Matching order

An exact = match wins first. Then the longest prefix is remembered; if it uses ^~ the search stops. Otherwise regex locations (~ and ~*) are tried in file order, and the first match wins over the prefix.

Test before you reload

Paste your pattern and sample URIs into the tester to see exactly what matches, then copy the expression into your config.

Open the Regex tester generator

Frequently asked questions

What is the difference between ~ and ~*?

~ is case-sensitive and ~* is case-insensitive.

Do I need to escape dots?

Yes. An unescaped dot matches any character, so \.php$ is correct and .php$ is not.

Guides