Skip to content

Redirect Rule Tester (.htaccess & nginx)

Paste Apache .htaccess or nginx rules, enter a test URL, and see which rule fires, the resulting URL and the HTTP status code. Runs free in your browser.

Runs entirely in your browser. Nothing you paste here is sent to us or anyone else โ€” there is no server processing, no logging of input, and no third-party scripts on this page.

A redirect rule tester lets you paste your Apache .htaccess or nginx rewrite rules, type in a test URL, and instantly see which rule fires, the URL it produces, and the HTTP status code โ€” without deploying anything. The tool above evaluates the rules top to bottom, just like a real server, and prints a step-by-step trace so you can see exactly where a request lands. Everything runs in your browser; nothing you paste is sent anywhere.

What this tool does

Redirects are easy to get subtly wrong. A pattern that looks right can match too much, sit below a broader rule that swallows the request first, or fire with the wrong status code. Normally you only find out after pushing to production and watching the logs. This tester closes that loop locally: give it your rules and a path, and it walks the list in order, reports each rule as a hit or a miss, and shows the final destination and status.

Supported rule types

The tester covers the patterns you reach for most often on both servers:

Server Directive Example
Apache RewriteRule RewriteRule ^old/(.*)$ /new/$1 [R=301,L]
Apache Redirect Redirect 301 /legacy /modern
Apache RedirectMatch RedirectMatch 302 ^/promo/(.*)$ /deals/$1
nginx rewrite rewrite ^/team/(.*)$ /about/$1 permanent;
nginx return return 301 https://example.com$request_uri;
nginx location location = /contact { return 301 /contact-us; }

Regular-expression back-references ($1, $2 and so on) are substituted into the target, so capturing groups behave the way they do on the server.

Redirect versus internal rewrite

The single most useful distinction this tool makes clear is between a redirect and an internal rewrite. A redirect returns a 3xx status to the browser, which then fetches the new URL โ€” the visitor sees the address bar change. An internal rewrite (a RewriteRule with no R flag, or an nginx rewrite ... last) silently maps the request to a different file on disk; the response is an ordinary 200 and the URL never changes. Mixing these up is a common source of confusion, so the trace labels each outcome explicitly.

A worked example

Suppose you paste these Apache rules and test the path /blog/2024/hello-world:

RewriteRule ^old-page.html$ /new-page.html [R=301,L]
RewriteRule ^blog/([0-9]+)/([^/]+)$ /posts/$2 [R=301,L]
Redirect 301 /legacy /modern

The first rule is checked and does not match. The second matches: the year is captured but discarded, the slug hello-world is pulled into $2, and the result is a 301 redirect to /posts/hello-world. Because the rule carries the L flag, evaluation stops there and the third rule is never reached. The trace shows all of this at a glance.

Common redirect mistakes it helps catch

  • Order conflicts โ€” a broad rule placed above a specific one intercepts requests before the specific rule runs.
  • Wrong status code โ€” using a 302 where you meant a permanent 301, which quietly costs you SEO signals.
  • Leading-slash surprises โ€” Apache strips the leading slash for per-directory RewriteRule matching, so ^/blog often never matches.
  • Greedy patterns โ€” (.*) capturing more than intended and building a broken target URL.
  • Missing the L flag โ€” expecting a rule to be final when later rules keep rewriting the path.

Honest limits

This is a pattern simulator, not a byte-for-byte reimplementation of Apache or nginx. It does not evaluate RewriteCond guard conditions, query-string flags such as QSA, server variables like %{HTTP_HOST}, virtual-host or server-block context, or proxy passes. Rules that depend on those features may match differently in production. Use the tester to sanity-check ordering, capturing groups and status codes, then confirm anything critical against a staging server. Because the whole thing runs locally in your browser, it is safe to paste rules from private configuration files, and it keeps working even if you disconnect from the network.

Frequently asked questions

Which rule types does this tester support?

It handles the most common patterns: Apache RewriteRule (with R=301/302 and L flags), Redirect and RedirectMatch, plus nginx rewrite (last, break, redirect, permanent), return 301/302, and simple location blocks (exact, prefix and regex matches). Rules are evaluated top to bottom, exactly like the real servers.

Is this a full Apache or nginx engine?

No, and it deliberately says so. It simulates the common redirect and rewrite patterns you meet day to day. It does not evaluate RewriteCond conditions, query-string flags such as QSA, virtual-host or server-block context, environment variables, or proxying. Treat the result as a strong first check, not the final word.

Why does my RewriteRule pattern not match the leading slash?

In a per-directory .htaccess context, Apache strips the leading slash before matching, so a pattern like ^blog/(.*)$ matches the path blog/2024 rather than /blog/2024. This tester follows that convention for RewriteRule. RedirectMatch and nginx rewrite match against the full path including the leading slash.

What is the difference between a 301 and a 302?

A 301 is a permanent redirect: browsers and search engines cache it and pass link equity to the new URL. A 302 (or 307) is temporary and is not cached the same way. Use 301 when a page has genuinely moved for good, and 302 for short-lived detours such as maintenance or A/B tests.

What is an internal rewrite versus a redirect?

A redirect sends a 3xx status back to the browser, which then requests the new URL โ€” the address bar changes. An internal rewrite (RewriteRule without an R flag, or nginx rewrite with last/break) quietly maps the request to a different file on the server; the visitor never sees a new URL and the response is a normal 200.

Is anything I paste sent to a server?

No. Parsing and evaluation happen entirely in your browser with plain JavaScript. Nothing you paste is uploaded, logged, or stored, so it is safe to test rules from private configuration files.

Why did no rule match my test URL?

Either none of the patterns matched the path, or the rule that should match uses a feature this tester does not simulate (such as a RewriteCond guard). Check the trace: each rule is listed with whether it fired, so you can see exactly where evaluation stopped.

Does the order of rules matter?

Yes, enormously. Both Apache and nginx evaluate rules from top to bottom, and the first terminal match wins. A broad rule placed above a specific one can swallow requests before the specific rule is ever reached. The trace shows the order so you can spot these conflicts.