set_redirects({ redirects: [{ from: "/old-page", to: "/new-page" }, { from: "/sale", to: "https://example.com/sale", permanent: false }] }) REPLACES the whole list, so pass every rule you want to keep (read the current ones first). They run on the server before any page renders.
fromis a site path;tois a path or a full URL.permanentis true (301) unless you pass false (302). Up to 500 rules.- Exact path match only: no wildcards or patterns (add a rule per URL), a trailing slash is ignored, the first matching rule wins. A redirect only applies once it is published.
- Use it when a page's slug changes (
update_pagenamechanges the URL), a page is deleted, or a client's old site is replaced. Don't build a redirect out of a page file.