Redirects
A redirect sends a visitor who opens one address straight to another. Add a file named
_redirects to your project and list one rule per line to move old pages, rename
routes, or point a path at another site.
Applying redirects on a published site needs Lediv Pro. The file travels with your export on any plan, and hosts like Netlify and Cloudflare Pages read it natively.
Create the file
-
In the Files panel, create a file at the project root and name it
_redirects. - Write one rule per line.
- Publish the site for the rules to take effect.
Keep it at the root, next to package.json, not inside pages/ or
public/. Only the root file is read.
Write a rule
Each rule is a line with two or three parts separated by spaces:
/from /to [301|302] -
/fromis the path a visitor requests. It starts with/and carries no query string and no fragment. -
/tois where they end up, either a path on your site or an external address starting withhttps://. -
The status is optional and defaults to a permanent redirect (
301). Write302for a temporary one. No other value is accepted. Cloudflare Pages defaults the other way, so write the status on every rule if the same file has to work there too.
Blank lines are fine, and # starts a comment at the beginning of a line or at the
end of a rule. It has to be its own word, so /old /new # moved in May is a rule
with a comment while /old /new#moved is not.
Match many paths at once
- Wildcard. A
*as the last whole segment of/frommatches the rest of the path however deep it goes, and:splatcarries it over:/blog/*to/articles/:splatsends/blog/2024/helloto/articles/2024/hello. - Named segment. A
:namematches exactly one segment and can be reused:/user/:idto/profile/:idsends/user/42to/profile/42, and does not match/user/42/settings.
Names are letters, numbers and underscores, cannot repeat in /from, and every name
in the destination has to come from /from. A line that breaks any of this is
skipped, and the rest of the file keeps working.
The wildcard has to be a segment of its own, as in /blog/*. A glued prefix like
/blog* is not valid here and the line is skipped. Other hosts are looser about it,
so look for that form first when you bring a file over from one of them.
Which rule wins
Rules are read top to bottom and the first match wins, so put the most specific ones first.
A redirect beats a page at the same path. If a rule matches
/pricing, visitors are sent away even when your project has a
/pricing page, and that page becomes unreachable. Check that /from is
an address you no longer serve.
Example
# Send an old page to its new home
/old-page /new-page
# A temporary detour, so browsers do not cache it (302)
/webinar /webinar-2026 302
# Move an entire section, keeping the rest of the path
/blog/* /articles/:splat
# Match a single segment by name
/user/:id /profile/:id
# Point a route at an external site
/community https://forum.example.com
/legacy-contact /contact 301 # a comment can close a rule too Good to know
- Paths.
/old/,/old.html,/old/index.htmland/oldare the same address, so one rule covers them. Write real characters (/café), not escapes, because rules match the address the browser decoded. - Queries. Anything after
?is carried to the destination unless the destination sets its own. A#fragment in the destination is kept and the query goes before it. - Loops. A rule whose destination resolves to the requested address is ignored and the page is served as usual, so a catch-all cannot loop your site.
- Timing. Rules apply from the next publish, not from saving the file.