Nginx Location Matcher

Paste Nginx location lines to see which location is selected and why.

Status

Runs in your browser. No input is sent to a server.

How to use

Enter path and location lines, then click Match to inspect final selection and decision trace.

Notes (this tool)

  • Internal rewrites and try_files jumps are out of scope.
  • Invalid regex patterns are reported as warnings.

About this page

What does this tool do?

Given location definitions and a path, this tool estimates final match using common Nginx priority rules.

It visualizes conflicts among `=` / `^~` / prefix / `~` / `~*` to debug unexpected routing.

Matching rules (simplified)

  • 1) `location =` (exact match) has highest priority
  • 2) Select longest prefix match
  • 3) If that longest prefix is `^~`, it wins immediately
  • 4) Otherwise evaluate regex (`~` / `~*`) in order and use first match
  • 5) If no regex matches, use longest prefix

Notes

  • This tool focuses on location matching only; rewrite/try_files/internal jumps are not simulated.
  • Named locations (`@name`) are treated as non-URI match targets.

Referenced specs

  • Nginx: location directive
  • Nginx request processing model

FAQ

Why does regex location win unexpectedly?

If longest prefix is not `^~`, regex blocks are evaluated top-down and first match is chosen.

Can I input full URLs?

Yes. The matcher uses only the URL path portion internally.

References

  1. Nginx location directive
  2. Nginx request processing

These links are generated from site_map rules in recommended diagnostic order.

  1. Nginx Rewrite Checker — Simulate rewrite/return rules and inspect final transition
  2. Redirect Chain Inspect — Analyze redirect chains to detect loops and waste hops
  3. Location Inspect — Parse Location header and split destination URL
  4. HTTP Status Inspect — Analyze HTTP status codes and suggest handling direction

Redirects

Use status codes and Location chains to isolate redirect issues