Redirect Rule Generator

Generate redirect rules for nginx, Apache (.htaccess), and Netlify from a list of URLs. Supports 301/302, regex, and site-wide migrations.

One line: OldURL NewURL. Old URLs can be paths (/old), and new URLs can be either paths or full URLs.
๐Ÿ“ Drag and drop or click to select mapping list file (.txt/.csv)
You can also copy and paste two columns from Excel ยท Max 8MB
Options
๐Ÿ’ก In regex mode, if you use * , it automatically changes to (.*) , and the captured value is inserted into the new URL's * or $1 position. Example: /blog/* โ†’ /posts/*
nginx settings

Choose Status Code

CodeMeaningWhen to useSEO
301Permanent RedirectSite restructuring, domain migration, URL structure changesExisting ranking transfers to the new URL. Use this for restructuring.
302Temporary RedirectEvent pages, maintenance notices, A/B testingOld URL continues to be indexed. Using this for restructuring is a mistake.
308Permanent (retains method)When POST requests (e.g., API) need to be passed through directlyTreated the same as 301
307Temporary (retains method)HSTS internal redirects, etc.Treated the same as 302
โš  Do not redirect all old pages to the homepage. Google treats redirects that do not correspond to content as soft 404s and does not transfer existing rankings. Connect each old article to its closest new article with a 1:1 mapping. If there truly is no corresponding page, it is better to return a 410 (Gone).

What is the Redirect Rule Generator?

When you restructure a website or move to a new domain, old URLs become dead ends. This breaks bookmarks and, more importantly, erases your hard-won search engine rankings. This tool helps you create the necessary 301 redirect rules to seamlessly guide visitors and search bots to your new pages. Just paste a list of old and new URLs, and it instantly generates the correct configuration for nginx, Apache (.htaccess), and Netlify. It also has a dedicated mode for site-wide rules like forcing HTTPS, standardizing www, or migrating an entire domain.

How to use

  1. Select a mode: "๐Ÿ“‹ Individual URL Redirect" to work from a list, or "๐ŸŒ Entire Domain Redirect" for site-wide changes.
  2. In individual mode, paste your URLs into the "Old URL โ†’ New URL" box, with one pair per line (e.g., /old-path /new-path).
  3. Choose your server from the "Server Format" options: "nginx", "Apache (.htaccess)", or "Netlify (_redirects)".
  4. Select a "Status Code", typically "301 โ€” Permanent Redirect (RestructureยทDomain Migration)" for permanent changes.
  5. For advanced cases, enable options like "Process as regex/wildcard patterns" to redirect URL patterns like /blog/* to /posts/*.
  6. Copy the generated rules from the output box and paste them into your server's configuration file.

Redirect Rule Generator guide

How this tool is used in real work, and what to watch out for.

The Pitfalls of Using 302 for a Site Redesign

If a URL has changed for good, use a 301. This isn't a matter of preference. A 301 is a signal to "forget the old URL and use the new one," prompting search engines to transfer the index and existing ranking signals to the new address. A 302 means "go somewhere else for a bit," so search engines keep the old URL in their index.

Using a 302 for a redesign leads to this state a few months later: the old URL keeps appearing in search results, the new URL isn't indexed, and the value of any new links you build gets trapped at the old address. Even if you later fix it with a 301, it takes more time for things to transfer again.

Conversely, using a 301 for something you plan to revert is also risky. Browsers cache 301s aggressively, so even after you remove the rule, visitors' browsers will keep redirecting to the new address for a while. For things you'll soon roll back, like event pages or maintenance notices, use a 302.

308 and 307 are equivalent to 301 and 302, respectively, but they preserve the original request method (like POST). A 301 is sufficient for redirecting standard web pages. Consider a 308 when moving API endpoints. Search engines treat 308 like 301, and 307 like 302.

Chains and Loops โ€” What This Tool Catches

A redirect chain is a sequence like Aโ†’Bโ†’C. They often happen after multiple site redesigns. If you set up /oldโ†’/new in the first redesign, and then add /newโ†’/final in the second, visitors coming to the old URL get bounced twice.

Google will generally follow a few hops, but each step adds a round-trip, slowing down the page load and wasting crawl budget. The perceived speed difference is significant on mobile. The solution is simple: update the old rules to point directly to the final destination. Create two lines: /oldโ†’/final and /newโ†’/final.

This tool warns you if it finds a chain within the rules you've entered and shows you the actual path. It also catches infinite loops that redirect to themselves. However, it can't know about chains created by old rules already on your server, so you should check your existing configuration files before deploying.

bash
# Check how many hops a redirect actually takes โ€” -L follows all the way
curl -sIL https://example.com/old-page | grep -E "^HTTP|^[Ll]ocation"

# Example result (2-hop chain โ€” needs fixing)
#   HTTP/2 301
#   location: https://example.com/new-page
#   HTTP/2 301
#   location: https://example.com/final-page
#   HTTP/2 200
A warning appears if you have three or more rules redirecting to the homepage (/). Google treats redirects to non-equivalent content as soft 404s and doesn't pass on ranking signals. If there's truly no corresponding new page, it's better to serve a 410 (Gone) status than to redirect to home โ€” search engines will de-index it faster.

URL Migration Process for a Site Redesign

Following these steps can minimize ranking loss. This is a battle-tested process.

  1. Gather a complete list of old URLs. Combine data from Google Search Console's Pages report (indexed URLs), your existing sitemap.xml, web server access logs, and other webmaster tools (like Bing's). Using logs helps you catch URLs that even search engines don't know about.
  2. Map old URLs to new ones on a 1-to-1 basis, starting with the pages that get the most traffic. If you're short on time, accurately mapping just the top 20% of URLs can preserve most of your traffic.
  3. Copy your mapping list, created as two columns in a spreadsheet (Old URL / New URL), and paste it directly into this tool.
  4. Apply the rules to a staging environment first. Spot-check a few URLs with `curl -I`, then deploy to production (e.g., `nginx -t โ†’ systemctl reload nginx`).
  5. Replace your sitemap with one containing the new URLs and resubmit it. Also, update all internal links to point directly to the new addresses. Don't let your own site rely on redirects.
  6. If you also changed your domain, use Search Console's Change of Address tool. You must keep the old domain running with the 301 redirects for at least one year.
  7. For several weeks, monitor Search Console for indexing status and 404 errors, and add any missed URLs.
You can copy and paste two columns from a spreadsheet or drag and drop a .csv file. The tool recognizes spaces, tabs, commas, and arrows (โ†’, ->, =>) as separators.

Server-Specific Pitfalls

The same rule can have unique gotchas depending on the server.

  • nginx: The `location` block cannot match query strings (e.g., `?id=3`). This tool creates an `if` statement that compares `$request_uri` for any URL containing a `?`. This `if` block must be placed inside your `server` block, but outside any `location` blocks.
  • nginx domain normalization: To redirect HTTPS requests, an SSL certificate for that domain must be in place first. If you just add a `www`โ†’`non-www` rule without a certificate for the `www` subdomain, visitors will see a certificate error before the redirect happens. The same applies to domain migrations; you must continue to renew the old domain's SSL certificate.
  • Apache: `.htaccess` files apply immediately without a server restart, but if your rules aren't working, check that `AllowOverride All` is set in your Apache config and that `mod_rewrite` is enabled (`a2enmod rewrite`). For hundreds of rules, performance is better if you move them into the virtual host configuration, as `.htaccess` is read on every request.
  • Netlify: Forcing HTTPS and standardizing your www/non-www domain is best handled in the Domain management section of the Netlify dashboard, so you don't need to add rules for this in `_redirects`. Only the first matching rule from the top down is applied. To make a rule take precedence over existing files, add a `!` after the status code.
  • Regex Mode: Rules are evaluated from top to bottom. If you place a broad pattern like `/*` at the top, more specific rules below it will never be reached. Place narrower rules first.
The "Retain query string" option can create invalid URLs like `?a=1?b=2` if the new URL already has its own query string. If you've added query parameters to your new URLs, turn this option off and visually inspect the generated rules.

Frequently asked questions

When should I use a 301 vs. a 302 redirect?

Use 301 for permanent moves, like a site restructure. This tells search engines to transfer SEO value to the new URL. Use 302 for temporary changes, like for an event page, as it keeps the original URL indexed.

Does this tool send my URL list to a server?

No. All redirect rules are generated directly in your browser. The list of your old and new URLs is never uploaded or stored anywhere, ensuring your site structure remains private.

Where do I put the generated nginx rules?

Rules for individual URLs should be placed inside your `server { }` block. Before applying, always check syntax with `nginx -t`, then reload gracefully with `systemctl reload nginx`.

Can I just redirect all my old pages to the homepage?

It's a bad practice. Google often treats these as "soft 404s" and won't transfer search rankings. For best SEO results, create 1-to-1 redirects from each old page to its most relevant new equivalent.