301 Redirect Rule GeneratorFor Next.js, Apache, Nginx And More
Paste a list of old and new URLs and get ready-to-use redirect rules. The tool checks for loops, duplicates, and chains before you publish, so a bad rule doesn't cost you traffic.
Runs in your browser. Your URLs are not uploaded or stored.
One rule per line, separated by a comma, tab, or ->. Use a trailing /* on both sides to move a whole section, like /old-blog/*, /blog/*. A header row is fine.
2. Options
3. Choose your platform and copy the rules
Paste your redirects on the left and the rules will appear here.
Step-by-step
How to create 301 redirect rules with this tool
Six steps from a list of old URLs to tested redirect rules for your hosting setup.
1.List every old URL and where it should go
Write one rule per line: old URL, new URL, and an optional status code. Paths like /old-page are enough, and full URLs work too. Moving a whole section? End both sides with /*, as in /old-blog/*, /blog/*.
2.Pick the closest matching destination for each page
Send each old URL to the page that best answers the same need, not just to the home page. Redirecting many unrelated pages to one generic destination can look like a soft 404 to search engines.
3.Read the safety checks
The tool flags redirect loops, redirects to the same URL, conflicting duplicates, query-string sources, and characters that could break a server config. It also flattens chains so visitors make one hop, not several.
4.Choose your platform and copy the rules
Pick Next.js, Vercel, Netlify or Cloudflare Pages, Apache, or Nginx. Copy the output or download it as a file, and add it to your site's configuration using the note shown under the code.
5.Deploy and test with curl
Run curl -I against a handful of old URLs. You should see the status code you chose and a location header pointing at the new URL. Test a pattern redirect and a URL that should not redirect too.
6.Update links, your sitemap, and monitor Search Console
Change internal links to point straight at the new URLs, replace old URLs in your sitemap, and watch Search Console for crawl errors over the following weeks.
Redirect best practices
- Use 301 or 308 for permanent moves. They tell search engines the move is permanent. Use 302 or 307 only when the old URL will return.
- Redirect one-to-one wherever you can. A relevant destination keeps visitors and search engines on-topic. Reserve broad redirects for sections that genuinely moved together.
- Avoid chains. Point every old URL directly at the final destination. Each extra hop slows the page and adds a chance of error.
- Keep redirects in place. Leave them live for at least a year, or for as long as the old URLs still receive links or traffic.
- Keep a record of the map. Export the cleaned CSV so you can audit, hand over, or re-create the rules on another platform later.
Common mistakes to avoid
- Redirecting everything to the home page, which usually gives visitors an irrelevant landing page.
- Creating loops, such as A → B and B → A, which make the page unreachable.
- Putting a ?query string in a source rule and expecting the server to match it. Most servers match the path only.
Learn the method
What is a 301 redirect and when should you use one?
A redirect automatically sends visitors and search engine crawlers from one URL to another. A 301 redirect signals that the move is permanent, so the old URL's links and history can carry over to the new one. Redirects protect your traffic whenever a URL changes, but they only help when they're accurate, direct, and free of loops.
301, 302, 307, and 308: which status code to use
| Code | Name | What it means | Typical use |
|---|---|---|---|
| 301 | Moved permanently | A permanent move. Search engines treat the new URL as the replacement. | Changed URLs, merged pages, site restructures |
| 308 | Permanent redirect | Permanent like 301, but the request method (such as POST) is preserved. | Permanent moves of endpoints that receive form or API requests |
| 302 | Found (temporary) | A temporary move. The old URL is expected to come back. | Short-term campaigns, A/B tests, maintenance pages |
| 307 | Temporary redirect | Temporary like 302, but the request method is preserved. | Temporary moves of endpoints that receive form or API requests |
For most SEO work on ordinary pages, 301 is the standard choice. Next.js uses 308 when you set permanent: true, so this tool writes the exact status code you pick instead.
When to set up a redirect
- A page's URL changes, for example after renaming a slug or restructuring folders.
- Two pages are merged into one stronger page.
- You move a section, such as /old-blog/ to /blog/.
- You retire a page that has a close replacement.
If a removed page has no relevant replacement, a 404 or 410 response is usually more honest than redirecting it to an unrelated page.
Redirect chains and loops
A chain happens when A redirects to B, and B redirects to C. Visitors and crawlers must follow every hop, which slows loading and wastes crawl effort. A loop happens when pages redirect back to each other, so the page never loads. This tool detects both: it flattens chains to the final destination and leaves loops out of the output.
Where each platform expects the rules
| Platform | Where it goes | Notes |
|---|---|---|
| Next.js | next.config.js → redirects() | Uses :path* for sections. Set statusCode to control the exact status. |
| Vercel | vercel.json → redirects | Same path syntax as Next.js. |
| Netlify / Cloudflare Pages | _redirects file | One rule per line, with /* and :splat for sections. |
| Apache | .htaccess or virtual host | RedirectMatch rules from mod_alias. |
| Nginx | server { } block | rewrite rules, which run in order. |
How each platform treats query strings, trailing slashes, and upper-case URLs differs, so always test a few real URLs with curl -I after deploying.
Finish the migration
Redirects are one part of a clean move. Decide which pages to merge with the Keyword Cannibalization Finder, list only the new URLs in a fresh sitemap.xml, and tell search engines about the changes with the IndexNow URL Submitter. Then update your own links with the Internal Link Opportunity Finder.
Browse all toolsQuestions and answers
Redirect rule generator FAQ
Which platforms does the redirect generator support?
Next.js (next.config.js), Vercel (vercel.json), Netlify and Cloudflare Pages (_redirects), Apache (.htaccess using mod_alias), and Nginx (rewrite rules).
What is the difference between a 301 and a 302 redirect?
A 301 signals a permanent move, so search engines treat the new URL as the replacement. A 302 signals a temporary move. Use 301 for permanent URL changes. 308 and 307 are the permanent and temporary equivalents that also preserve the request method.
Can I redirect a whole folder?
Yes. End both the old and new URL with /*, for example /old-blog/*, /blog/*. Everything under the old folder is redirected to the same path under the new one. You can also send a whole section to a single page by leaving the * off the destination.
Why were some of my rules rejected?
The tool leaves out rules that would loop, redirect a URL to itself, conflict with an earlier rule, match on a ?query string, or contain characters that can't be written safely into server configs. Each rejection is listed with its line number and the reason.
Does this redirect www to non-www or http to https?
No. Those are host-level rules, usually set up in your hosting or DNS settings. This tool creates path-level redirects for individual URLs and sections.
Is my list of URLs uploaded anywhere?
No. Everything runs in your browser, and nothing is sent to a server.
