Skip to content
Visit Pages on GitHub
Set theme to dark (⇧+D)


Creating redirects

To use redirects on Cloudflare Pages, declare your redirects in a _redirects plain text file in the output folder of your project. The build output folder is project-specific so the _redirects file should not always be in the root directory of the repository. Changes to redirects will be updated to your website at build time so make sure you commit and push the file to trigger a new build each time you update redirects.

Only one redirect can be defined per line and must follow this format:

[source] [destination] [code?]

A complete example with multiple redirects may look like the following:

/home301 / 301
/home302 / 302
/querystrings /?query=string 301
/trailing /trailing/ 301
/notrailing/ /nottrailing 301

A project is limited to 100 total redirects. Each redirect declaration has a 1000-character limit. Malformed definitions are ignored. If there are multiple redirects for the same source path, the topmost redirect is applied. If the same source URL has multiple redirects, the topmost redirect is applied.

Cloudflare currently offers limited support for advanced redirects. More support will be added in the future.

Redirects (301, 302)Yes/home / 301
Rewrites (other status codes)No/blog/* /blog/404.html 404
SplatsNo/blog/* /blog/:splat
PlaceholdersNo/blog/:year/:month/:date/:slug /news/:year/:month/:date/:slug
Query ParametersNo/shop id=:id /blog/:id 301
Force (shadowing)No/workers/ /workers/index.html 200!
Domain-level* 301
Redirect by country or languageNo/ /us 302 Country=us

Additional information