How do I create redirects on Cloudflare Pages?

The Citead team, updated

In short. Place a plain text _redirects file in the static asset output and write one source, destination and optional status code per line.

Definition: As of 17 October 2026, Cloudflare Pages uses a plain text file named _redirects, with no file extension, to configure redirects for static asset requests. Each rule gives a source path, a destination and an optional HTTP status code.

Key facts

Where does the file go?

Cloudflare's placement instructions put _redirects in the project's static asset directory. With a framework, public/ or static/ often contains assets copied into the final output during the build. Without a framework, the file can sit directly in the build output directory.

The resulting deployment must contain _redirects in that output. Pages parses the file and applies its rules to static asset responses; the configuration file itself is excluded from static asset serving.

What syntax does a redirect use?

Cloudflare's per-line format is:

[source] [destination] [code?]

The brackets describe the fields; actual rules use paths and values, as in these examples from the same documentation:

/home301 / 301
/home302 / 302
/querystrings /?query=string 301
/twitch https://twitch.tv

The destination accepts a local path or an external URL, including a query string or fragment. Supported redirect status codes are 301, 302, 303, 307 and 308. Omitting the code selects 302, as in the external-link example. A line beginning with # is a comment. A rule with an invalid format is ignored.

How do patterns capture parts of a path?

A splat is a wildcard written as * that captures all matching characters. Cloudflare's pattern documentation allows a single splat in a URL and inserts its captured value into the destination with :splat.

A named placeholder captures a value under a name introduced by a colon. In a path, its match stops at a forward slash. The same documentation gives these examples:

/blog/* /posts/:splat
/movies/:title /media/:title

Placeholder names begin with a letter and contain letters, digits or underscores. Each named placeholder can be referenced only once. The destination can also place captured values into a query string:

/products/:code/:name /products?code=:code&name=:name

What limits and exceptions affect the rules?

Cloudflare's file rules allow up to 2,000 static redirects and 100 dynamic redirects, with a 1,000-character limit per declaration. Static rules belong before dynamic rules. Where several rules share a source path, the topmost rule applies. A matching redirect also applies when an asset exists at the requested path.

The same documentation excludes requests served by Pages Functions. Those routes need redirect logic in the Function or exclusion from Functions routing. Redirects also run before _headers rules.

FAQ

Can I redirect to another website?

Yes. Cloudflare's destination syntax accepts external links, as shown by /twitch https://twitch.tv.

Can I use a URL fragment in a rule?

You can include a fragment in the destination. The same documentation explains that source fragments are ignored because the browser evaluates them.

Can I serve another local page without changing the browser URL?

The same documentation describes proxying with status 200, for example /blog/* /news/:splat 200. This serves content from another relative URL on the site; external domains are excluded from proxying.

Sources

  1. Cloudflare, "Redirects", updated 25 August 2026
  2. Cloudflare, "Build configuration", updated 18 September 2026
  3. Cloudflare, "Routing", updated 18 September 2026

Check how a page reads to answer engines. Open the GEO score analyzer

Test a page and see what to fix first

The analysis usually takes less than 10 seconds and needs no account.

400,000+ pages scored in the public benchmark