.htaccess / Redirect Rules Generator.
Turn a list of old → new URLs into Apache .htaccess, nginx or Netlify redirect rules.
Runs in your browserAbout .htaccess / Redirect Rules Generator
This generator turns a plain list of redirects into rules your server understands, which is the tedious part of every site migration. Write one rule per line as "source target status", for example "/old-page /new-page" for a permanent 301, "/promo /sale 302" for a temporary one or "/legacy 410" for a page that is gone for good. A source ending in /* matches a whole section, so "/blog/* /news/:splat" moves every article while keeping its slug. A source with a query string such as /products?id=42 matches only that exact query and drops it from the new URL. For Apache you get a mod_rewrite block for .htaccess, with paths written the way RewriteRule sees them (no leading slash, decoded, optional trailing slash) and back-references escaped so a literal $ or % in a target cannot break the rule. For nginx you get location blocks and server-level checks to paste into the server block, and for Netlify a _redirects file. Query strings of the visitor are kept on every redirect, matching what Apache does by default. Optional rules force HTTPS and move traffic between www and the bare domain; they come first so most visitors take a single hop. Warnings point out rules the target cannot express, sources that appear twice (only the first one wins) and redirects that point to themselves and would loop. Use 301 or 308 only for moves you will keep: browsers cache permanent redirects aggressively. Everything is generated in your browser.
How to Use
- Paste your redirects, one "source target [status]" rule per line, for example exported from a spreadsheet.
- Choose Apache, nginx or Netlify and decide on HTTPS and www handling.
- Copy the rules into .htaccess, the nginx server block or _redirects and test a few URLs before going live.
Frequently Asked Questions
Should I use 301 or 308?
Both are permanent. 301 lets clients turn a POST into a GET, 308 keeps the method. For ordinary page moves 301 is the usual choice; 302 and 307 are their temporary versions.
Why does the Apache rule have no leading slash?
In .htaccess files RewriteRule matches the path relative to the directory, so /old-page is matched as "old-page". The generated pattern also accepts a trailing slash.
Are query strings kept?
Yes, the visitor's query string is passed on, except for rules whose source matches a specific query string; those drop it so the new URL stays clean.
Is my list of URLs uploaded?
No. The rules are generated in your browser and nothing is sent to a server.
Related Tools
Generate an nginx server block for static sites, SPAs, PHP-FPM, Laravel or a reverse proxy, with HTTPS.
Trace redirect chains, detect loops, and measure timing.
Reference for all HTTP status codes.
Encode and decode URL components.
Test regular expressions with match highlighting.
Split AWS ARNs into partition, service, region, account and resource, or build an IAM policy statement.