Redirect Generator (.htaccess/Nginx)
Software · 4 inputs · Free
Redirect Generator (.htaccess/Nginx)
Parameters
What is this tool?
Redirect Generator (.htaccess/Nginx) helps developers with encoding, encryption and text processing. Generates redirect rules that move old URLs to new ones for Apache .htaccess (mod_alias Redirect or mod_rewrite RewriteRule) and Nginx (location = … { return … }). Write the old path and the new address on each line, separated by a space: "/old-page /new-page" or "/blog/old https://www.example.com/new"; put a URL containing spaces in double quotes. Regex characters are escaped, old URLs with a query string (?id=5) are matched with RewriteCond or $args, and redirect loops or an old path listed twice are reported with the line number. An HTTPS or www redirect can be added as well.
📘 Common mistakes · Worked exampleGenerates redirect rules that move old URLs to new ones for Apache .htaccess (mod_alias Redirect or mod_rewrite RewriteRule) and Nginx (location = … { return … }). Write the old path and the new address on each line, separated by a space: "/old-page /new-page" or "/blog/old https://www.example.com/new"; put a URL containing spaces in double quotes. Regex characters are escaped, old URLs with a query string (?id=5) are matched with RewriteCond or $args, and redirect loops or an old path listed twice are reported with the line number. An HTTPS or www redirect can be added as well.
The result is not exact or binding and is for information only; it is not an official document and cannot be used in official procedures. Confirm it with the competent authority or a professional before acting; no liability is accepted for losses arising from its use.
Last reviewed: · Methodology and sources
How is it calculated?
Generates redirect rules that move old URLs to new ones for Apache .htaccess (mod_alias Redirect or mod_rewrite RewriteRule) and Nginx (location = … { return … }). Write the old path and the new address on each line, separated by a space: "/old-page /new-page" or "/blog/old https://www.example.com/new"; put a URL containing spaces in double quotes. Regex characters are escaped, old URLs with a query string (?id=5) are matched with RewriteCond or $args, and redirect loops or an old path listed twice are reported with the line number. An HTTPS or www redirect can be added as well.
Inputs
| Value | Unit | Example |
|---|---|---|
| Rules (one per line: old-path new-url) | — | /old-page /new-page /blog/old-post https://www.example.com/blog/new-post |
| Status code | — | 301 (permanent) |
| Server | — | Apache .htaccess (Redirect) |
| Extra rule | — | None |
What is this tool?
Redirect Generator (.htaccess/Nginx) helps developers with encoding, encryption and text processing. Generates redirect rules that move old URLs to new ones for Apache .htaccess (mod_alias Redirect or mod_rewrite RewriteRule) and Nginx (location = … { return … }). Write the old path and the new address on each line, separated by a space: "/old-page /new-page" or "/blog/old https://www.example.com/new"; put a URL containing spaces in double quotes. Regex characters are escaped, old URLs with a query string (?id=5) are matched with RewriteCond or $args, and redirect loops or an old path listed twice are reported with the line number. An HTTPS or www redirect can be added as well.
Common mistakes
- Using 302 for a permanent move, or 301 for a temporary situation. A 301 is cached by browsers and hard to take back; a 302 on a permanent move gives search engines the wrong signal.
- Building redirect chains. Adding new rules on top of old ones creates A → B → C chains; point every old URL straight at the final one.
- Creating a loop. Rules such as /a → /b and /b → /a, or a Redirect that points into its own sub-path, end with a "too many redirects" error in the browser.
- Assuming Redirect matches exactly. Redirect 301 /blog /new also sends /blog/post-1 to /new/post-1; if you mean a single page, you need RewriteRule or RedirectMatch.
- Trying to match the query string in the Redirect or RewriteRule pattern. The pattern is compared with the path only; for the ?id=5 part, use RewriteCond %{QUERY_STRING}.
- Writing a RewriteRule pattern that starts with ^/ in .htaccess. The leading slash is stripped in that context, so the pattern never matches; use ^/? or ^ without the slash.
- Editing the live .htaccess without a backup. A single bad line can bring the whole site down with a 500 error; make sure you can restore the previous file.
- Moving a URL that receives form posts with 301 or 302. The client may turn the request into GET and the form data is lost; use 307 or 308 to preserve the method.
📘 How to Set Up a 301 Redirect: .htaccess and Nginx Rules, 301 vs 302 vs 307 vs 308 →
Sources
- RFC 9110 — HTTP Semantics, section 15.4: Redirection 3xx ↗
- Apache HTTP Server 2.4 — mod_alias, Redirect directive ↗
- Apache HTTP Server 2.4 — mod_rewrite, RewriteRule directive ↗
- Apache HTTP Server 2.4 — .htaccess files: troubleshooting ↗
Key terms
Frequently Asked Questions
+Redirect Generator (.htaccess/Nginx) — how is it calculated?
Generates redirect rules that move old URLs to new ones for Apache .htaccess (mod_alias Redirect or mod_rewrite RewriteRule) and Nginx (location = … { return … }). Write the old path and the new address on each line, separated by a space: "/old-page /new-page" or "/blog/old https://www.example.com/new"; put a URL containing spaces in double quotes. Regex characters are escaped, old URLs with a query string (?id=5) are matched with RewriteCond or $args, and redirect loops or an old path listed twice are reported with the line number. An HTTPS or www redirect can be added as well.
+Which values are required?
Rules (one per line: old-path new-url), Status code, Server, Extra rule.
+Is my data stored?
No. All calculations run in your browser; the values you enter are never sent to or stored on a server. If you press “Save”, the calculation stays only in your own browser and you can delete it at any time.
+Is it free?
Yes, all tools are free and require no sign-up.
Similar tools
Popular Tools
Free Calculators in One Place
Tax, finance, health, math and more — 500+ tools, all in one place.