← All text tools

Nginx Location Match Tester

Paste nginx location blocks and a request URL to see which block is chosen and why, following the exact, prefix, regular expression and longest prefix rules.

  • Free
  • No sign-up
  • Works on any device

About Nginx Location Match Tester

Nginx picks one location block for each request by fixed rules. This tester reads your location blocks and a request path and walks through the same steps: an exact match with = ends the search; otherwise the longest matching prefix is remembered, and if it carries the ^~ modifier the search ends there; otherwise regular expressions (~ and ~*) are tried in file order and the first match wins; if none matches, the longest prefix is used. Example: with a prefix /images/ and a regex for image extensions, the request /images/logo.png is served by the regex block.

How to use Nginx Location Match Tester

  1. Paste your location blocks, one after another, as they appear in the nginx configuration.
  2. Type the request URL or path you want to test.
  3. Read the chosen location, the explanation of each step and the table showing which blocks matched.

Why use this tool?

Also known as

Frequently asked questions

Why does a regex location beat my longer prefix location?

Because a plain prefix match is only remembered while nginx checks regular expressions in order. A matching regex replaces it, unless the prefix was written with ^~, which stops the search at once.

Does the query string take part in matching?

No. Nginx matches on the normalized path: the query string is removed, percent codes are decoded and repeated slashes are merged by default.

What is not covered?

Nested location blocks, named locations that start with @, if blocks, rewrites and try_files. Regular expressions run in the JavaScript engine of your browser, which matches nginx PCRE for common patterns but not every feature.

Is Nginx Location Match Tester free?

Yes. Nginx Location Match Tester on Toolipedia is free to use, with no sign-up and no watermark.

Is it safe to use?

Yes. Everything is worked out in your browser, and nothing you enter is sent to our server.

Does it work on my phone?

Yes. It works in any modern browser on Android and iPhone, as well as on tablets and computers. There's nothing to install.

Do I need an account?

No. Just open the page and use the tool. There's no sign-up and no email needed.