Redirects
Send visitors from an old address to a new one.
Add a file named _redirects at the top level of your site. Each line gives an old path and its destination. The format supports common Netlify redirect rules, with the differences listed below.
# a page that moved
/old-page /new-page
# a whole section. * matches the rest, :splat puts it back.
/blog/* /articles/:splat
# one segment, by name
/team/:name /people/:name
# a temporary redirect
/sale /products/summer 302
# retiring old CMS links: ?id=42 becomes /products/42
/store id=:id /products/:id
# redirect to another website
/discord https://discord.gg/example- One rule per line: the old path, the new one, and optionally a status code. Without one the redirect is a 301; 302, 303, 307 and 308 are also accepted. Anything after
#is a comment. - The first matching rule wins, so put specific rules above wildcards. A trailing slash makes no difference: a rule for
/aboutalso matches/about/, and/docs/*also matches/docsitself. - Query parameters that the rule does not use are kept on the new address, so a
?utm_sourcesurvives the redirect.
When rules run
An existing file takes priority over a redirect. If you’re moving a page, remove the file at the old address so its redirect can run. Redirects are checked before the 200.html and 404.html fallbacks.
Not supported
- Rewrites with status 200, which fetch another address and serve it under yours.
- Forced rules, written with
!, that override an existing file. - Conditions on the visitor’s country or language. A rule that has one is skipped entirely rather than applied to everyone.
- A source path that mixes
*with:name, or that contains a?. To match on a query parameter, use thekey=:valueform shown above.
Limits
| Limit | Value | If you cross it |
|---|---|---|
| File size | 64 KB | The whole file is ignored |
| Rules read | 500 | The rest are not read |
| Destination length | 2 KB | That rule is skipped |
Like every file in your site, _redirects is public: anyone can read it at /_redirects.