Redirect Rule Generator
Generate 301, 302, 307 and 308 redirects as .htaccess, nginx, Netlify, Vercel or Cloudflare rules from a bulk list, with loop and chain detection built in.
How to use Redirect Generator
- 1Paste one rule per line as old new [status], for example /old-page /new-page 301, and choose the output format.
- 2Add site-wide options if you need them, such as force HTTPS, www or non-www, a trailing slash policy or a domain move.
- 3Read the warnings, copy or download the file, and test it on a staging site. Use Check to find loops and chains in rules you already have.
What makes it better
- Five outputs: Apache .htaccess, nginx, Netlify _redirects, Vercel vercel.json and a Cloudflare Bulk Redirects CSV
- Regex characters, spaces and dollar signs are escaped per platform, and old URLs with a query string become a QUERY_STRING condition or $arg_ test
- Detects loops such as /a to /b to /a, chains such as /a to /b to /c, duplicates and specific rules placed under a wildcard
- Check can produce a cleaned list with chains pointed at their final destination and duplicates and loops removed
- A trailing * in the old URL carries the rest of the path over, for example /blog/* to /news/*
About Redirect Generator
Redirect Rule Generator turns a list of old and new URLs into redirect rules for Apache .htaccess, nginx, Netlify _redirects, Vercel vercel.json or a Cloudflare Bulk Redirects CSV, escaping paths and query strings for each platform. Site-wide options cover force HTTPS, adding or removing www, trailing slashes and moving one domain to another. The Check mode reads rules written as old, new and status, and reports loops, chains, duplicates and rules hidden behind a wildcard.
Common uses
- Map hundreds of old URLs to new ones after a redesign or a move to a new CMS, from a spreadsheet column pair.
- Move a site from http to https and from www to the bare domain without creating a two-step redirect chain.
- Retire an old domain by sending every URL to the same path on the new domain.
- Audit a redirect list a previous developer left behind to find loops that cause too many redirects errors.
Example
Input
/old-pricing /pricing /blog/2019/post /blog/post 301 /summer-sale /sale 302 /products?id=42 /products/42
Result
# Test on a staging site first. Browsers cache 301 and 308 redirects, so a mistake can linger for visitors.
<IfModule mod_rewrite.c>
RewriteEngine On
# Page redirects
RewriteRule ^old-pricing$ /pricing [R=301,L]
RewriteRule ^blog/2019/post$ /blog/post [R=301,L]
RewriteRule ^summer-sale$ /sale [R=302,L]
RewriteCond %{QUERY_STRING} ^id=42$
RewriteRule ^products$ /products/42? [R=301,L]
</IfModule>
Good to know
- Permanent redirects (301 and 308) are cached by browsers, sometimes for a long time. Use 302 or 307 while testing, try the rules on a staging site, and keep a copy of the previous configuration.
- Output is meant to be pasted into the right place: .htaccess in the site root with mod_rewrite enabled, nginx rules inside your server block, _redirects in the publish folder, vercel.json in the project root. Platform behaviour with query strings differs, so test those URLs.
- Site-wide rules for HTTPS, www and trailing slashes are not available in every format: Vercel and Netlify handle some of them in their dashboards, and Cloudflare Bulk Redirects only holds URL-to-URL rows. The tool says so when it skips one.
Redirect Generator FAQ
What is the difference between 301, 302, 307 and 308?
301 and 308 are permanent, 302 and 307 are temporary. 307 and 308 also require the browser to repeat the same method (for example POST), while 301 and 302 let it switch to GET. For moved pages, 301 is the usual choice.
How do I redirect one URL in .htaccess?
With mod_rewrite enabled, add RewriteEngine On and a line such as RewriteRule ^old-page$ /new-page [R=301,L] to the .htaccess file in your site root. The pattern has no leading slash because .htaccess rules are matched relative to the directory.
How do I redirect www to non-www, or the other way?
Enter your domain, choose Remove www or Add www and the tool writes the host condition for your platform. When Force HTTPS is on as well, the rules send visitors straight to the final address instead of making two hops.
What is a redirect chain and why does it matter?
A chain is /a redirecting to /b, which redirects to /c. Each extra hop slows the page and loses a little link value, and crawlers may stop following long chains. Point the first URL directly at the last one; Check can rewrite the list for you.
Can I redirect only URLs that have a certain query string?
Yes. Write the old URL with its query, such as /product?id=42. Apache gets a RewriteCond on QUERY_STRING, nginx gets an $arg_ or $args test, Netlify and Vercel use their parameter matching, and Cloudflare Bulk Redirects cannot match queries so those rows are skipped.