Skip to content

Generated rules

Paste your old → new URL pairs on the left (or try the example) to generate redirect rules.

This tool checks one thing. Our audit checks 190+.

DarnItSEO Audit scans your entire site and writes the fix instructions for every issue it finds. Included in every yearly plan.

From a list of moved URLs to rules your server understands

When a page moves, the old address needs an instruction that sends people and crawlers to the new one. Writing those instructions by hand is fiddly: Apache, Nginx, Netlify and Vercel all use different syntax, special characters need escaping, and query strings need their own handling. This generator takes a plain list of old and new URLs, one pair per line, and writes the rules for the platform you pick.

It supports four outputs: Apache .htaccess (mod_rewrite), Nginx, a _redirects file for Netlify or Cloudflare Pages, and vercel.json. You choose 301 (permanent), 308 (permanent, keeps the request method) or 302 (temporary). Along the way it skips rules that would redirect a URL to itself, warns about duplicate old URLs (the first one wins), spots chains inside your own list (A to B and B to C) and can flatten them so A goes straight to C, and detects loops in the list. Everything runs in your browser; nothing is sent to a server.

What goes in and what comes out

Paste old and new URLs separated by a space, tab or comma. Old URLs can be paths or full addresses, and can include a query string. Lines starting with # are ignored, so you can paste a commented spreadsheet export.

/blog/2019/post-title   https://example.com/blog/post-title
/products?id=42         /products/blue-widget
/about-us/              /about

For Apache, that list becomes:

# Add to .htaccess at your site root (needs mod_rewrite)
RewriteEngine On

RewriteRule ^blog/2019/post\-title/?$ https://example.com/blog/post-title [R=301,L,NE]
RewriteCond %{QUERY_STRING} ^id=42$
RewriteRule ^products/?$ /products/blue-widget? [R=301,L]
RewriteRule ^about\-us/?$ /about [R=301,L,NE]

And for Nginx:

# Add inside the server { } block of your Nginx config
location ~ ^/blog/2019/post\-title/?$ { return 301 https://example.com/blog/post-title; }
if ($request_uri = "/products?id=42") { return 301 /products/blue-widget; }
location ~ ^/about\-us/?$ { return 301 /about; }

Each rule matches the old path with or without a trailing slash, so /about-us and /about-us/ both redirect. The trailing ? in the Apache query rule drops the old ?id=42 from the new address, so it does not get carried onto the clean URL.

301, 308 or 302: which code to pick

For moved content, use a permanent redirect. 301 is the familiar choice and works everywhere. 308 means the same thing to search engines but also guarantees a form POST stays a POST, which matters if any old URL receives form submissions. Vercel's permanent: true always sends 308; Google treats it the same as 301.

Use 302 only when the old URL is coming back, such as a short promotion or a page that is temporarily offline. Google has said all redirect codes pass PageRank, so the real cost of a wrong 302 is that Google may keep showing the old URL in results instead of the new one. Our guide to redirect codes covers the edge cases.

Exact rules, not wildcards

This generator writes one exact rule per line of input. It does not create pattern rules like "send everything under /old-blog/ to /blog/". That is deliberate: a pattern that is slightly too broad can catch URLs you never meant to touch, and those mistakes are hard to spot on a live site. If you do need a folder rule, write it by hand, place it below the exact rules, and test a handful of URLs it should and should not match.

Where to paste the output

Apache (.htaccess)

Back up the file first. Paste the rules near the top of .htaccess in your site root, above WordPress's own "BEGIN WordPress" block if you run WordPress, so your redirects run before the CMS handles the request. Apache reads .htaccess on every request, so changes apply immediately.

Nginx

Paste the lines inside the server block for your HTTPS site, run nginx -t to check the syntax, then reload Nginx. If you have many rules, keep them in a separate file such as redirects.conf and include it from the server block.

Netlify, Cloudflare Pages and Vercel

Save the _redirects output in your publish folder (Netlify) or build output folder (Cloudflare Pages). Cloudflare Pages ignores query-string matches, and the tool warns you when that applies. For Vercel, merge the redirects array into your existing vercel.json rather than replacing the whole file.

WordPress and Shopify without server access

On managed WordPress hosting without .htaccess access, add the same pairs in the Redirection plugin or your SEO plugin's redirect manager. On Shopify, use the URL Redirects screen in the admin, which also accepts a CSV import of old and new paths.

Chains inside your own list

Over several migrations, redirect lists end up with entries like /a to /b and, later, /b to /c. Leave them as they are and visitors to /a take two hops. Turn on "flatten chains" and the generator points /a straight at /c. It only sees chains within the list you paste, though. If your live server already redirects /c somewhere else, or adds an HTTPS or www hop first, check the result with the Redirect Chain Checker after deploying.

Planning redirects for a site migration

Every old URL that had traffic, rankings or backlinks needs a redirect to its closest equivalent new page. Build the list before launch, not after: export your current URLs from your sitemap, analytics and backlink tool, map each one, and generate the rules so they go live with the new site. Send each old page to the most relevant new page rather than the homepage; Google often treats mass redirects to the homepage as soft 404s.

After launch, test a sample of redirects, update internal links to point at the new URLs directly, submit the new sitemap, and watch Search Console for old URLs returning 404. Keep the redirects in place for at least a year, and ideally for good, because old links and bookmarks keep arriving long after the move.

How it works

  1. Choose Your Platform and Code

    Pick Apache (.htaccess), Nginx, Netlify / Cloudflare Pages (_redirects) or Vercel (vercel.json), and choose 301, 308 or 302.

  2. Paste Old and New URLs

    Enter one pair per line, separated by a space, tab or comma. Paths, full URLs and query strings are supported, and lines starting with # are ignored.

  3. Copy or Download the Rules

    Get escaped, ready-to-paste rules, with warnings for duplicates, self-redirects, loops and chains, plus an option to flatten chains automatically.

Frequently asked

Which platforms can this generator write rules for?

›

Apache .htaccess (mod_rewrite), Nginx server blocks, a _redirects file for Netlify or Cloudflare Pages, and a redirects array for vercel.json. Pick the one that serves your site; rules for the wrong platform simply will not run.

Should I choose 301, 308 or 302?

›

Use 301 or 308 for permanent moves; search engines treat them the same, and 308 also keeps form POSTs as POSTs. Use 302 only when the old URL is coming back. Vercel's permanent setting always sends 308.

Can it redirect URLs with query strings?

›

Yes. Paste an old URL like /products?id=42 and the rule matches that exact query string. On Apache the old query is dropped from the new address. Cloudflare Pages ignores query matches in _redirects, and the tool warns you when that applies.

What does 'flatten chains' do?

›

If your list contains /a to /b and /b to /c, flattening rewrites the first rule to send /a straight to /c, so visitors and crawlers take one hop instead of two. It only sees chains inside the list you paste, not redirects already on your server.

Does it create wildcard or folder rules?

›

No. It writes one exact rule per line, which avoids accidentally catching URLs you did not mean to redirect. Each rule matches the old path with or without a trailing slash. If you need a folder-wide rule, write it by hand and test it carefully.

Where do I put the generated rules?

›

Apache: near the top of .htaccess in your site root, above any CMS block. Nginx: inside the HTTPS server block, then run nginx -t and reload. Netlify or Cloudflare Pages: a _redirects file in the publish or output folder. Vercel: merge into the redirects array in vercel.json.

Should I redirect deleted pages to the homepage?

›

Only as a last resort. Google often treats mass redirects to the homepage as soft 404s, so the old page's signals may not carry over. Redirect each old URL to the most relevant live page instead.

Is my URL list sent to a server?

›

No. The rules are generated in your browser, so the URLs you paste are not uploaded.

Related tools

More Technical SEO tools

See all Technical SEO tools · All free SEO tools

Related guides

↳ full site audit190+ checks · AI fix instructions · yearly plans