Redirects
A redirect sends a visitor who opens one address straight to another. List one rule per line in
a file named _redirects 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.
Only the file at the root is read, next to package.json. One inside
pages/ or public/ is ignored.
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://. Anhttp://address is not accepted. -
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. A word that starts with # starts a comment, at the beginning
of a line or after a rule. So /old /new # moved in May is a rule with a comment,
while in /old /new#moved the #moved is part of the destination.
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 use letters, numbers and underscores, cannot repeat in /from, and cannot be
splat. Every name in the destination has to come from /from. The
wildcard has to be a segment of its own, as in /blog/*, so a glued prefix like
/blog* is invalid. A line that breaks any of this is skipped, and the rest of the
file keeps working. After publishing, the Publish panel lists the lines it skipped and any rules
it discarded. Other hosts are looser about the glued form, so look for it 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 is a path that resolves to the requested address is ignored and the page is served as usual, so a catch-all cannot loop your site. Two rules that send visitors back and forth still can, so check pairs.
- Timing. Rules apply from the next publish, not from saving the file.