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

Redirects

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 repo. 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.

Redirects can be stated as such with one redirect per line in the form:

[source][destination] [code]

_redirects/home301 / 301/home302 / 302/querystrings /?query=string 301/twitch https://twitch.tv/trailing /trailing/ 301/notrailing/ /nottrailing 301

There is a limit of 100 redirects and a 1000 character limit per redirect line. Incorrectly formatted lines in the file are ignored. If there are multiple redirects for the same source, the topmost redirect is applied.

We currently offer limited support for advanced redirects. More support will be added in the future.

FeatureSupportExample
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 redirectsNoworkers.example.com/* workers.example.com/blog/:splat 301
Redirect by country or languageNo/ /us 302 Country=us

See also