Overview
Introduction
A Cloudflare Pages _redirects file is plain text, but its column-based from/to/status syntax and the distinction between a 200 rewrite and a 301/302 redirect are easy to mix up, especially the first time.
This tool builds the file from a list of rows you fill in, plus two ready-made examples (an SPA fallback and a whole-domain redirect) you can drop in with one toggle each.
What Is Cloudflare Pages _redirects File Generator?
A generator for Cloudflare Pages' _redirects file: repeatable rows for a source path, a destination, and a status code (301, 302, or 200), plus two optional canned examples for the two most common special cases.
The output is plain text, ready to save as _redirects at the root of your Pages build output.
How Cloudflare Pages _redirects File Generator Works
Each row becomes one line of `from to status`, matched against incoming request paths in the order Cloudflare evaluates them (first matching rule wins).
The SPA fallback toggle appends a commented `/* /index.html 200` rule, and the domain redirect toggle appends a commented `https://old/* https://new/:splat 301` rule using the domains you provide, with the `:splat` placeholder carrying over the matched path.
When To Use Cloudflare Pages _redirects File Generator
Use it when migrating a site to a new domain and needing every old URL to 301 to its equivalent new one, or when deploying a client-side-routed SPA that needs a catch-all fallback.
It's also useful for consolidating a handful of one-off legacy redirects (old blog slugs, renamed pages) into a single well-formatted file.
Often used alongside Cloudflare Pages _headers File Generator, Cloudflare Staging Domain Blocker and pages.dev Duplicate Content Checker.
Features
Advantages
- Outputs the exact from/to/status column format Cloudflare Pages expects, with consistent spacing.
- Includes the two most commonly needed special-case redirects as one-toggle examples instead of requiring you to remember their exact syntax.
- Supports any number of custom rows alongside the canned examples.
Limitations
- Cloudflare Pages evaluates _redirects rules top-to-bottom and stops at the first match, this tool preserves your row order but doesn't warn you about a broad early rule shadowing a narrower later one.
- Doesn't validate that destination paths or domains actually exist, only that both a "from" and "to" value were entered.
Examples
Best Practices & Notes
Best Practices
- List more specific redirect rows before broader catch-all ones, since Cloudflare stops at the first match.
- Prefer 301 for permanent moves you want search engines to re-index under the new URL, and 302 only for genuinely temporary redirects.
- Keep the SPA fallback rule (if used) as the very last rule in the file, so it only catches paths nothing else matched.
Developer Notes
Cloudflare Pages' _redirects parser reads each non-comment, non-blank line as whitespace-separated `from to [status]` columns and evaluates rules top-to-bottom, stopping at the first match; this generator preserves the row order you build in the form and appends the two canned examples (each prefixed with an explanatory `#` comment) after your custom rows.
Cloudflare Pages _redirects File Generator Use Cases
- Migrating a site to a new domain with permanent redirects for every old path
- Adding a catch-all SPA fallback so a client-side router handles deep links correctly
- Consolidating scattered legacy URL redirects into one reviewable file
Common Mistakes
- Placing a broad `/*` rule before more specific rules, causing the specific ones to never be reached.
- Using a 301 for a redirect that's still being tested, permanent redirects get cached aggressively by browsers, making later changes hard to see take effect.
Tips
- Pair the domain-level redirect example with the Staging Domain Blocker tool if the domain you're redirecting away from is a pages.dev staging subdomain you want de-indexed too.