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.
Choose Status Code
| Code | Meaning | When to use | SEO |
|---|---|---|---|
| 301 | Permanent Redirect | Site restructuring, domain migration, URL structure changes | Existing ranking transfers to the new URL. Use this for restructuring. |
| 302 | Temporary Redirect | Event pages, maintenance notices, A/B testing | Old URL continues to be indexed. Using this for restructuring is a mistake. |
| 308 | Permanent (retains method) | When POST requests (e.g., API) need to be passed through directly | Treated the same as 301 |
| 307 | Temporary (retains method) | HSTS internal redirects, etc. | Treated the same as 302 |
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
- Select a mode: "๐ Individual URL Redirect" to work from a list, or "๐ Entire Domain Redirect" for site-wide changes.
- In individual mode, paste your URLs into the "Old URL โ New URL" box, with one pair per line (e.g., /old-path /new-path).
- Choose your server from the "Server Format" options: "nginx", "Apache (.htaccess)", or "Netlify (_redirects)".
- Select a "Status Code", typically "301 โ Permanent Redirect (RestructureยทDomain Migration)" for permanent changes.
- For advanced cases, enable options like "Process as regex/wildcard patterns" to redirect URL patterns like /blog/* to /posts/*.
- 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.
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.
# 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
URL Migration Process for a Site Redesign
Following these steps can minimize ranking loss. This is a battle-tested process.
- 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.
- 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.
- Copy your mapping list, created as two columns in a spreadsheet (Old URL / New URL), and paste it directly into this tool.
- 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`).
- 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.
- 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.
- For several weeks, monitor Search Console for indexing status and 404 errors, and add any missed URLs.
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.
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.