DoItWithAI.tools Logo

Technical SEO · Multi-Platform 301/308 Migration Compiler

301 Redirect RuleGenerator & Chain Checker

Convert a list of old and new URLs into production-ready redirect rules for Next.js, Apache (.htaccess), Nginx, Cloudflare, and Vercel—while automatically flattening chains.

Next.js, Nginx, Apache & VercelAutomatic chain & loop detectionCSV bulk import & config export
Use in Do It AI →

4 Migration Safety Checks

  • Chain Flattening: Resolves A → B → C multi-hop redirects into a single direct hop.
  • Loop Prevention: Flags self-redirects and circular paths before deployment.
  • Duplicate Rules: Detects conflicting source paths mapped to different targets.
  • 5 Server Formats: Compiles exact syntax for Next.js, Apache, Nginx, Vercel, and CF.

Compiling server redirect rules & chain checks

Validating redirect mappings, flattening multi-hop chains, and generating config syntax.

Your results will open below when the check finishes.

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

Rules ready

6

Errors

4

Warnings

1

// next.config.js ; add this inside your config object
async redirects() {
  return [
    { source: "/blog/meta-description-length", destination: "/blog/how-to-write-meta-descriptions", statusCode: 301 },
    { source: "/blog/seo-for-beginners", destination: "/blog/keyword-research-guide", statusCode: 301 },
    { source: "/old-tools/seo", destination: "/tools", statusCode: 301 },
    { source: "/a", destination: "/c", statusCode: 301 },
    { source: "/b", destination: "/c", statusCode: 301 },
    { source: "/old-blog/:path*", destination: "/blog/:path*", statusCode: 301 },
  ];
},

Add the redirects() function to next.config.js (or next.config.mjs) and redeploy. A /old/* rule also matches /old itself in Next.js.

After deploying, test a few URLs with curl -I https://your-domain.com/old-page and check for the status code and a location header.

  • Error · line 8: /loop-1 is part of a redirect loop and was left out.
  • Error · line 9: /loop-2 is part of a redirect loop and was left out.
  • Error · line 10: Sources with a ?query string aren't supported ; server rules match the path only, so this one would redirect more than you intend. Remove it or configure that rule by hand.
  • Error · line 11: Redirects /same to itself.
  • Warning · line 6: Redirect chain (/a → /b → /c). Flattened so /a goes straight to /c.
  • Note: Hostnames were removed from sources. Rules apply on whichever site the config is installed.

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. 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. 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. 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. 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. 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. 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

CodeNameWhat it meansTypical use
301Moved permanentlyA permanent move. Search engines treat the new URL as the replacement.Changed URLs, merged pages, site restructures
308Permanent redirectPermanent like 301, but the request method (such as POST) is preserved.Permanent moves of endpoints that receive form or API requests
302Found (temporary)A temporary move. The old URL is expected to come back.Short-term campaigns, A/B tests, maintenance pages
307Temporary redirectTemporary 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

PlatformWhere it goesNotes
Next.jsnext.config.js → redirects()Uses :path* for sections. Set statusCode to control the exact status.
Vercelvercel.json → redirectsSame path syntax as Next.js.
Netlify / Cloudflare Pages_redirects fileOne rule per line, with /* and :splat for sections.
Apache.htaccess or virtual hostRedirectMatch rules from mod_alias.
Nginxserver { } blockrewrite 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 tools

Questions 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.