Redirect rule generator

Paste one redirect per line, the old URL then the new one, and pick where the rules will run. The generator writes nginx, Apache .htaccess, _redirects (Cloudflare Pages, Netlify) or a CSV for a redirect plugin, and warns you when a rule points at another old URL (a chain) or at itself (a loop).

  • 3 redirects, no chains or loops found.
Redirect rules
# inside the server { } block
map $request_uri $redirect_target {
    default "";
    "/old-page/" "/new-page/";
    "/blog/2019/05/hello-world/" "/blog/hello-world/";
    "/services.html" "https://example.com/services/";
}

if ($redirect_target) {
    return 301 $redirect_target;
}

Choosing where redirects live

WhereGood forWatch out for
Server (nginx, Apache)Large maps, whole-domain moves, speedNeeds server access; a typo can take the site down
CDN or edge (_redirects, rules)Static and headless sites, moves off a platformPer-plan limits on rule counts
WordPress pluginEditors managing a few hundred URLsRuns after WordPress loads, so slightly slower

When you are leaving a hosted platform such as Wix or Squarespace, the old platform usually cannot redirect once the domain points elsewhere, so the rules must live wherever the domain now resolves.

Why chains matter

If /a/ redirects to /b/ and /b/ redirects to /c/, every visitor and crawler takes two hops. Google follows several hops but each one costs time and a little reliability, and long chains after repeated migrations are common. Point every old URL straight at the final destination. The chain warning above catches the cases inside the list you pasted; the redirect chains guide covers finding the ones already on your site.

Query strings and trailing slashes

The nginx output matches the full request URI, so /page?ref=1 and /page are different keys: list both if both were linked. The Apache output adds a RewriteCond for query strings and drops them from the target with a trailing ?. Trailing slashes also count: /services and /services/ are different URLs, so match what was actually live.

Common questions

Should I use 301 or 302?

Use 301 for permanent moves such as migrations and changed slugs. Use 302 only when the old URL will come back, like a seasonal page.

How long should I keep redirects after a migration?

As long as you can. Google has said at least a year, but old links and bookmarks keep arriving for much longer, and redirects cost almost nothing to keep.

Can I redirect everything to the homepage?

Avoid it. Google treats mass redirects to an unrelated page as soft 404s. Redirect each URL to its closest match, and let truly dead pages return 404 or 410.