Redirects
When a page moves, a redirect sends visitors and search engines from its old URL to the new one, so links keep working and the page keeps its search ranking.
Redirects work on your own custom domains, not on hostsmith.link addresses. Add a custom domain and create the site on it first. To forward a hostname that has no site, such as a domain you no longer use, create a redirect host instead.
A site's rules come from two places:
- User rules, which you add in the dashboard, or through the API and AI agents. They are kept on the site, and a deploy doesn't change them.
- A
_redirectsfile in your site, whose rules go live with each deploy.
Add rules in the dashboard
In the dashboard's sites list, choose a site's Redirects action. The panel lists the site's rules in the order they are checked.
- Add rule opens a row for the old path, where to send it, and the status code. Done checks the rule.
- On each rule's row, you can move it up or down, edit it, or delete it.
- Save applies all your changes together, within about 5 minutes.
- Edit as text shows the rules as
_redirectslines, for many changes at once. - Test a path shows which rule answers a path, and where it sends visitors. While you have unsaved changes, it tests those.
If someone else saves the rules while you edit them, Save says so, and offers to load their version.
Import and export
- Export saves the user rules as a CSV with the columns
from,toandstatus, or as_redirectslines to put in your site. - Import reads the same CSV, or Webflow's export. It shows the rules, and each row it can't use with the reason, before saving anything. Once you confirm, the imported rules replace the user rules, and the rows with errors are left out. The
_redirectsrules don't change.
Forward a domain with a redirect host
A redirect host is a hostname on one of your custom domains that has no site: it answers only with its user rules. Use one to forward a domain you no longer use to your new one, or for short campaign links such as go.example.com/spring.
- In the sites list, choose Add, then Redirect. The choice shows once one of your custom domains is active.
- Choose its address.
- To send every path to another site, fill in Forward every path to, such as
https://new-brand.com. That saves the rule/* https://new-brand.com/:splat, sowww.old-brand.com/pricing?utm_source=mailgoes tohttps://new-brand.com/pricing?utm_source=mail. Leave it empty to add your own rules in the Redirects panel, which opens next.
A path that no rule matches gets the not-found page. To forward the bare domain too, create the redirect host at www with Serve at apex: a visitor to old-brand.com/pricing goes to www.old-brand.com/pricing first, then to the destination, as described in The bare domain.
A redirect host has no files, so it takes no deploys and no _redirects file, and it can't have access control. It doesn't count toward your plan's site limit, and an organization can have up to 50. Through the API, create one as a site with kind set to redirect; an AI agent can create one too. Delete it like a site, from the sites list.
Add a _redirects file
Put a file named _redirects at the root of your site, next to index.html, and deploy. Write one rule per line:
# The blog moved to /news
/blog/* /news/:splat
/about-us /about
/pricing https://shop.example.com/plans 302
Each line is the old path, where to send it, and an optional status code, separated by spaces. Lines that start with # are comments.
- The rules go live with the deploy, and a later deploy without the file has no rules.
- The file itself is never served:
/_redirectsis not-found. - In a ZIP, put it at the root, or in the single top folder if the ZIP has one. A
_redirectsin any other folder is an ordinary file. - A deploy of only a
_redirectsfile is fine: it publishes the rules, with no pages.
Netlify and Cloudflare Pages read the same format, so a _redirects file from either works for the rules on this page.
Paths
- Exact paths match with or without a trailing slash:
/about-usmatches/about-usand/about-us/. - A splat,
*as the last part of the path, matches the path and everything under it. In the destination,:splatis the rest of the path: with/blog/* /news/:splat,/blog/2024/ryegoes to/news/2024/rye./*matches every path. - Placeholders such as
:slugmatch one part of the path, between two slashes: with/posts/:slug /articles/:slug,/posts/fresh-ryegoes to/articles/fresh-rye. - Case matters, as it does for files:
/Teamdoesn't match/team. - Encoded characters match as the visitor's browser shows them, so
/über-unsmatches a link to/%C3%BCber-uns.
The destination is a path on your site, or a full https:// or http:// URL. Placeholders can fill in a destination's path or query, never its domain.
Status codes
| Code | Use it for |
|---|---|
| 301 | A page that moved for good. The default when a line has no code. |
| 302 | A page that moved for a while |
| 303 | Sending a visitor to another page after a form |
| 307 | A temporary move that keeps the request's method, such as a POST |
| 308 | A permanent move that keeps the request's method |
Search engines treat a 301 or a 308 as the page's new address, and a 302 or a 307 as a short detour.
Order
Rules are checked from the top, and the first one that matches answers: the user rules first, then the _redirects rules, and both before your site's files. A rule for /pricing applies even when pricing.html exists.
A user rule for the same path as a _redirects rule overrides it, and the Redirects panel marks that _redirects rule as overridden.
Put specific rules above broad ones. In this file, /shop/sale never reaches line 2:
/shop/* /store/:splat
/shop/sale /deals
A broad rule such as /* sends every page away. Check the rules in the site's Redirects panel after a deploy.
Query strings
The visitor's query string goes along to the destination: with /old /new, /old?utm_source=newsletter goes to /new?utm_source=newsletter. When the destination has its own query string, such as /new?ref=old, that one is used instead.
Redirects are never cached, so each visitor gets their own query string, and a rule that a deploy removes stops at once. A page the CDN has kept at a path that has just gained a rule can still be served for up to 5 minutes.
Lines that don't work
A line with a mistake is skipped, and the rest of the file applies, so a typo doesn't stop a deploy. The sites list shows how many lines a site's live deploy skipped, and the site's Redirects panel lists each one with the reason. A user rule with a mistake is never saved: the panel shows the mistake on the rule.
These aren't supported, and are skipped:
- rewrites with status 200, and 404 rules;
- conditions, such as a country, a language or a cookie;
- a full URL as the old path, or a query string in it;
- a rule that sends a path to itself.
Turn off a deploy's _redirects
When a deployed _redirects sends visitors to the wrong place, turn off Apply the rules from _redirects in the site's Redirects panel. Within about 5 minutes, the site serves its pages again, and the user rules keep applying. The rules stay off until you turn them back on, or until the next deploy goes live with its own _redirects.
Limits
The same on every plan, for the _redirects file and for the user rules each:
- up to 1 MB, about 13,000 rules of a usual length;
- up to 20,000 rules;
- of those, up to 1,000 rules with a
*or a placeholder; - up to 1,000 characters a line.
A _redirects file over 1 MB applies no rules, and rules past the other limits are skipped. A change to the user rules that would pass a limit isn't saved, and says which limit.
From Webflow
Export your 301 redirects as a CSV from the Webflow site's settings, then import the file in the site's Redirects panel with Import, Webflow export. Each redirect becomes a user rule with status 301. A trailing (.*) in the old path becomes a splat, and %1 in the new one becomes :splat:
| In Webflow | As a rule |
|---|---|
/blog/(.*) to /news/%1 | /blog/* /news/:splat |
/about-us to /about | /about-us /about |
Other Webflow patterns, such as (.*) in the middle of a path, a capture other than (.*), or %2, have no _redirects form. The import lists each one as an error, leaves it out, and imports the rest. Add those rules by hand, with a placeholder where one fits.
To keep the redirects with your site's files instead, write the same rules as lines of a _redirects file, or import them and then Export them as _redirects lines.
The bare domain
A site on the bare domain, such as example.com, is served at www.example.com. A visitor who opens example.com/old is first sent to www.example.com/old, and the rule applies there. Both redirects keep the path and the query string.