Redirect Rule Generator
List your old and new URLs, move whole folders, retire pages with a 410, force HTTPS and pick www or non-www. Get tested, ready-to-paste redirect code for your server, and trace any URL through the rules before you go live.
- 8 platforms from .htaccess to Next.js
- Built-in tester shows every hop
- Catches loops and redirect chains
Matching old URLs to new ones first? Use the Redirect Mapping Tool, then verify the live result with the SEO Migration Redirect Checker.
Every common redirect, written for your platform
Pick your server, list what should move, and the tool writes the rules in the right syntax and the right order.
Single page redirects
One line per old and new URL. Paste from a spreadsheet, a CSV export or write old -> new. Query-string URLs such as /page.php?id=5 are supported.
Folder redirects
Move /blog/ to /articles/ and every URL beneath it follows, with the rest of the path and the query string kept.
Gone pages (410)
Pages with no replacement can answer 410 Gone, which tells crawlers the removal was deliberate.
HTTPS and www
Force HTTPS and a single canonical host in one redirect, including the version for sites behind Cloudflare or a load balancer.
Clean URLs
Add or remove trailing slashes and strip .html or .php from URLs without creating loops.
Domain migrations
Send every URL on the old domain to the same path on the new one, including the www version.
301, 302, 307, 308 or 410: which one to use
The status code tells browsers and search engines whether a move is permanent. Using a temporary code for a permanent move is one of the most common redirect mistakes.
| Code | Meaning | Use it when | Search engines |
|---|---|---|---|
| 301 | Moved Permanently | A page has a new address for good. The default choice for migrations. | Treated as a permanent move: the new URL replaces the old one in the index and ranking signals follow. |
| 308 | Permanent Redirect | Same as 301, but the request method (POST, PUT) is kept. | Google treats it like a 301. |
| 302 | Found | A short, temporary detour such as a sale page or maintenance. | The old URL usually stays indexed while the redirect is temporary. |
| 307 | Temporary Redirect | Same as 302, with the method kept. | Treated like a 302. |
| 410 | Gone | A page was removed on purpose and has no replacement. | A clear removal signal. Google handles it much like a 404. |
How to create and publish your redirects
Four steps take you from a list of old URLs to rules running on your server.
Choose your platform
Pick Apache, Nginx, IIS, Cloudflare, Netlify, Vercel, Next.js or CSV. You can switch platforms later and keep the same list.
List the redirects
Paste old and new URLs, add folder moves, mark removed pages and tick the site-wide rules you need.
Test and fix
Trace sample URLs in the Test tab and read the Checks tab for loops, chains and duplicates.
Upload and verify
Copy the code to the file named above the code box, deploy it and run the SEO Migration Redirect Checker on the live URLs.
Redirect rules that protect your rankings
A redirect only helps if it sends visitors and crawlers to the right place, quickly and permanently.
Send each URL to its closest match
Redirect to the page that now covers the same topic. Redirects to the home page or to unrelated pages are treated as soft 404s.
Avoid chains
Point every old URL straight at the final address. Google follows up to 10 hops, but every hop slows visitors and wastes crawl budget.
Keep redirects for at least a year
Google recommends keeping site-move redirects for as long as possible, and at least a year, so signals are transferred.
Update your own links
Change internal links, canonical tags and the XML sitemap to the new URLs instead of relying on the redirect.
Test before and after
Trace URLs here before deploying, then confirm status codes and destinations on the live site.
Use 301 for permanent moves
302 and 307 tell search engines the old URL may come back. Use them only when that is true.
What a redirect rule generator writes and why the syntax matters
A redirect rule is a line of server configuration that answers a request for one URL with a 3xx status and the address of another. Every platform has its own way of writing it. Apache uses Redirect, RedirectMatch or mod_rewrite. Nginx uses return or rewrite inside a server block. Netlify, Vercel and Next.js each read a different file format. A rule that is correct in one is meaningless in another.
The details decide the result. In Apache, [Redirect with no status gives a temporary 302](https://httpd.apache.org/docs/current/mod/mod_alias.html), and it matches a path prefix, then appends whatever follows. In Nginx, the [return directive](https://nginx.org/en/docs/http/ngx_http_rewrite_module.html) sends a redirect for codes 301, 302, 303, 307 and 308, and it does not do pattern matching. A generator handles those differences, escapes special characters, orders the rules and writes the output in the right file.
The code only counts once it is live. A generator cannot see your CMS, your CDN or the rules already on the server, so the last step is always to request the URLs and read the answers. This page covers writing the rules. Planning which old URL goes where is a separate job, and checking the live result is another.
When to generate redirect rules
Use it whenever a known list of addresses must change and you want code you can paste instead of write.
Moving a whole section
Rename /blog/ to /articles/ with one folder rule instead of one line per post. The rest of the path and the query string carry over.
Applying a redirect map
You already know every old and new URL from a spreadsheet. Paste the pairs and get the rules in the syntax your server needs.
Forcing HTTPS and one host
Combine the HTTPS rule and the www choice into one redirect, including the version for sites that sit behind a proxy or load balancer.
Changing domain
Send every URL on the old domain to the same path on the new one, www version included, then handle the exceptions separately.
Retiring pages for good
Mark pages with no replacement as 410 Gone instead of redirecting them to an unrelated page. The output differs on every server.
Moving between hosting platforms
A site moving from Apache to Nginx, or to Netlify or Vercel, needs its old redirects translated. Switch the platform and keep the same list.
Redirect rule mistakes and how to fix them
Rule bugs hide well, because the page usually still loads. Check the status code and the destination, not just the page.
Forgetting the status code
What goes wrong: Apache's Redirect defaults to a temporary 302 when no status is given, so a permanent move is sent as temporary and the old URL may stay in results.
The fix: State the status. Use Redirect permanent, an explicit 301, or let the generator write it. Confirm afterwards with a redirect trace.
Prefix rules that carry the path
What goes wrong: Redirect "/blog" "/articles" also moves /blog/post-1 to /articles/post-1. That is right for a folder move and wrong when you meant one page.
The fix: Use an exact-match rule for a single page, and a folder rule only when everything below it should follow. Test a deep URL and the folder root.
Unescaped regular expressions
What goes wrong: In RedirectMatch and Nginx rewrite, a dot matches any character, and an unescaped $ or ? changes the meaning. A rule can catch URLs you never intended.
The fix: Anchor patterns with ^ and $, escape dots and query characters, and test URLs that should not match as well as those that should.
Rules in the wrong order
What goes wrong: A broad rule placed before a specific one swallows the request, so the specific rule never runs. This is common after pasting new rules at the end of a file.
The fix: Put specific rules first and general ones last. The tester in the tool follows the same order, so run sample URLs through it.
An HTTPS rule behind a proxy
What goes wrong: On Cloudflare with Flexible SSL, the origin sees HTTP for every request. An origin rule that forces HTTPS then loops forever.
The fix: Tick the proxy option in the generator so the rule reads the forwarded protocol, or move the HTTPS redirect to the edge as Cloudflare advises.
Redirecting a removed page to the home page
What goes wrong: Sending dozens of unrelated old URLs to one page does not help visitors. Google advises against redirecting many old URLs to one irrelevant destination.
The fix: Redirect to the closest equivalent page. If none exists, return 410 or 404 and let the page drop out.
Redirect rule terms explained
.htaccess- A per-directory configuration file read by Apache. Redirect rules placed here apply to requests for that folder and below, without editing the main server config.
mod_aliasandmod_rewrite- Two Apache modules that redirect.
mod_aliasoffers simpleRedirectandRedirectMatch.mod_rewriteusesRewriteRuleand conditions for complex logic. return 301- An Nginx directive that stops processing and sends a 301 redirect to a given URL. It needs no pattern, so it is simpler and clearer than a rewrite when you only need a fixed redirect.
- Regular expression
- A pattern language used to match many URLs with one rule. Characters such as
.,?and$have special meanings and often need escaping. - Exact match and prefix match
- An exact match applies to one URL only. A prefix match applies to every URL that begins with a path and passes the rest along.
- 410 Gone
- A status that says a page was removed on purpose and is likely not coming back. Apache can send it with
Redirect gone. - Proxy or load balancer
- A server in front of your own that terminates HTTPS. Your server may only see HTTP, so an HTTPS redirect has to read the forwarded protocol header.
- Rule order
- Many servers test redirect rules in sequence and act on the first match. A specific rule must come before a general one that would also match.
Related tools, guides and services
Generating rules sits in the middle of the job. These cover what comes before and after.
Redirect Mapping Tool
Decide which old URL should go to which new one before you write any rules.
ToolRedirect Checker
Trace a single URL through the live rules and read each hop.
ToolSEO Migration Redirect Checker
Test the whole list on the live site for wrong destinations, chains and noindex.
GuideRedesign SEO migration checklist
Follow the checks around the redirects: inventory, sitemap, canonicals and monitoring.
ServiceSEO migration service
Get redirect mapping, rules and post-launch checks handled for a site move.
ServiceTechnical SEO service
Have redirect, crawling and indexing setup reviewed by a specialist.
Built by
Madhav Kushwaha
SEO, AEO, GEO & Digital Marketing Consultant in Kathmandu, Nepal, and trainer at ODcrU Academy and TechAxis Institute. I built this generator because redirect code is easy to get subtly wrong: a missing escape, an unescaped dollar sign, a rule in the wrong order, or a chain nobody notices until traffic drops. The Apache, Nginx and Cloudflare output here was tested against the real servers, and the tester follows the same order the server does.
Redirect Rule Generator: Frequently Asked Questions
More free SEO tools
Redirects, sitemaps and robots.txt work together during a migration. Use these tools to plan, build and verify the whole move.