A .htaccess pattern must not start with a slash
This is the mistake that produces a file which looks completely correct and does nothing at all. In a .htaccess file — per-directory context — mod_rewrite strips the directory prefix from the path before matching. For a file at your document root, a request for /old-page is matched against old-page.
So a rule written RewriteRule "^/old-page$" "/new-page" [R=301,L] never matches anything. Ever. The generated rules here have no leading slash on the pattern side and keep the leading slash on the substitution side, which is the asymmetry that actually works — the substitution is what builds the Location header.
How to use it
- Paste your mapping list: the old path, a space, tab or comma, then the new path. One per line.
#starts a comment. - Add a third field to override the status for one line:
/promo /offers 302. - Choose the Match type and Query string policy, then press Generate or Ctrl/Cmd + Enter.
- Switch between Apache and Nginx to get the same rules in the other language.
Sources are paths, not URLs: no scheme, no host, no query string, no fragment. A query string in the source is refused rather than ignored, because ignoring it would produce a rule that fires more often than you asked for. A fragment is never sent to a server at all.
Prefix means the path or the path plus a slash
Prefix matches /blog and /blog/anything — and deliberately not /blogging. A plain "starts with" match is the more common implementation and the more common bug: it silently catches every path that happens to begin with the same letters.
Both generated forms enforce the segment boundary. On nginx that means a regex location rather than ^~, because ^~ is a prefix-string match with no notion of path segments and would match /blogging too.
In prefix mode every matching path collapses onto the single destination. Mapping /blog/post to /news/post — carrying the remainder across — is a separate feature this version does not have, and does not pretend to.
The query string, which does something different on every engine
This is the most dangerous divergence in the whole area. Apache's RewriteRule copies the original query unless your substitution has one of its own; nginx's rewrite appends it after your new arguments; nginx's return carries nothing at all. Three directives, three different defaults.
So this tool never relies on a default. Apache rules always carry an explicit [QSA] or [QSD], and nginx always uses return inside a location — never rewrite — so the generated value states the whole outcome and nothing can leak into it.
- Preserve carries the original query across. On nginx that is
$is_args$args, which is empty when the request had no query, so you never get a dangling?. - Discard drops it.
- Replace uses the query you wrote on the destination and drops the original.
Two combinations are refused rather than guessed: preserve or discard with a destination that already has a query ("keep the original and use mine" needs merge rules nobody has defined), and replace with a destination that has none. The message names the policy you probably wanted.
Case-insensitive matching, and what it costs on nginx
URL paths are case-sensitive, so /Old-Page and /old-page are different URLs — but a migration off a case-insensitive platform often needs both to redirect. Case-insensitive matching handles that: Apache gets the [NC] flag on every rule, and nginx gets the ~* operator.
On nginx that has one consequence worth knowing, and the generated file says so: there is no case-insensitive exact location, so every rule becomes a regex location. The match is identical, but the precedence changes — nginx normally evaluates exact locations before any regex one, and with them all regex they are evaluated in the order written instead. That actually brings the two engines closer together, since Apache has always worked in file order.
301 or 308? The difference is invisible until a form breaks
A 301 or 302 may turn a POST into a GET on the follow-up request. A 307 or 308 preserves the method. If anything ever POSTs to the old URL — a form, an API client, a webhook — that distinction is the difference between working and quietly losing data.
301 is the default here because migrations are the dominant use, but a 301 is cached aggressively by browsers and is hard to undo for anyone who has already followed it. If you are not sure yet, use a 302 or 307 and change it later.
What is refused, and why refusing is the point
Some things are caught before anything is generated at all: a redirect loop, a rule that redirects to itself, a protocol-relative destination (//host/path — the classic open-redirect shape), a javascript: or data: destination, and any control character in any field. That last one is the highest-severity case here: in a configuration file a newline does not corrupt a string, it injects a new directive.
And generation is refused entirely while any error remains — a shadowed rule, a duplicate source with two destinations. A rule that can never fire is worse than no rule, because the file looks finished. You get the findings instead, with the line numbers of both rules involved.
There is no regex match type. A "safe regex" checker cannot be written correctly for a pattern that will run on someone else's server under a different engine, and shipping one would be a false assurance. Every pattern in the output is generated here from an escaped literal, so products/c++.html matches itself and nothing else — and no pattern you did not write can run on your server.
Frequently asked questions
Does this test my redirects?
No, and every generated file says so in its header. Nothing here made a network request or executed a rule. Review the output and test it on staging before deploying — this tool tells you what your configuration says, not what your server does.
Why is my second rule reported as unreachable?
Because an earlier rule already matches its source, and Apache evaluates rules in file order. Move the more specific rule above the general one. Nginx complicates this: it evaluates exact locations before any regex location regardless of file order, so the same file can behave differently on the two servers — which is exactly why the ambiguous case is refused rather than emitted.
Can I paste this straight into an existing .htaccess?
Yes, but merge it into an existing RewriteEngine block rather than appending a second one — rule order across blocks is not what you would expect. The generated block is guarded with <IfModule mod_rewrite.c> so it cannot 500 a server without mod_rewrite.
Why was my %2F flagged?
Because Apache rejects encoded slashes by default and nginx decodes them before matching a location. The same rule will genuinely behave differently on the two servers, and no generated configuration can hide that.