Home / Redirect generator
301 redirect generator for .htaccess and nginx
Turn a list of old and new URLs into ready-to-paste rules, or generate one set of rules that sends every http, www and slash variant to your canonical host in a single hop. Runs entirely in your browser.
Separate with a space, tab or comma. Lines starting with # are skipped. Paste straight from a spreadsheet's two columns.
# .htaccess (Apache mod_rewrite). Place near the top, before CMS rules.
RewriteEngine On
RewriteRule ^old-page$ /new-page [R=301,L,NE]
RewriteRule ^blog/2019/seo-tips$ /guides/seo/ [R=301,L,NE]
RewriteCond %{QUERY_STRING} ^id=42$
RewriteRule ^shop$ /mugs/blue/ [R=301,L,NE,QSD]
Test on staging first, then verify with the bulk redirect checker. Browsers cache 301s hard; test in a private window.
.htaccess redirects: what to know
Redirect 301 /old /new(mod_alias) matches prefixes, so/oldalso catches/old-stuff. The generator uses anchoredRewriteRule ^old$patterns to match exactly.RewriteRulenever sees the query string. Sources with?id=42get aRewriteCond %{QUERY_STRING}line and theQSDflag so the old query isn't appended to the target.- Put redirects above WordPress or other CMS rewrite blocks, or they never run.
- On servers you control, the same rules in the virtual host config are faster than .htaccess, which Apache rereads on every request.
nginx redirects: what to know
- For more than a handful of URLs, a
mapis faster and tidier than dozens oflocationorrewritelines. nginx builds a hash table from it. return 301is preferred overrewrite … permanentwhen you don't need a regex.- Separate
serverblocks for the non-canonical hosts are the idiomatic way to do http→https and www redirects;if ($host …)inside the main block works but is harder to reason about. - Run
nginx -tbefore reloading.
Questions
Should I use 301 or 308?
For page moves, either. Google treats 301 and 308 the same. 308 guarantees the request method is kept (a POST stays a POST), which matters for forms and APIs, not for normal page links. 301 has the widest support in old tools.
Does the generator send my URLs anywhere?
No. Rules are built by JavaScript in your browser. Nothing you paste leaves the page.
What does "flatten to one hop" do?
If your map contains A → B and B → C, visitors to A would bounce twice. Flattening rewrites the first rule to A → C, so every old URL reaches its final page in a single redirect.
How do I redirect a whole domain to a new one?
Use a pattern that keeps the path: in Apache, RewriteRule ^(.*)$ https://new.com/$1 [R=301,L]; in nginx, return 301 https://new.com$request_uri; inside the old domain's server block. Then tell Google with the Change of Address tool in Search Console.