Redirects
Send visitors from one URL to another with routing.redirects in void.config.ts. Keys are source patterns; values are destinations or objects with a status code.
On this pageAdd permanent or temporary redirects · Match paths with patterns · Check how redirects are ordered
This example adds a simple redirect and a permanent wildcard redirect.
{
"routing": {
"redirects": {
"/old": "/new",
"/blog/*": { "to": "/posts/:splat", "status": 301 }
}
}
}Matching rules
- Source patterns start with
/.*matches any characters including/. - Destinations can be strings (default
302) or objects withtoand optionalstatus. Supported statuses:301,302,303,307,308. :splatin the destination is replaced with the portion of the path matched by*in the source pattern.- Destination query strings merge into the
Locationheader. On a key conflict, the destination's value wins. To drop the incoming query, end the destination with?. - If several rules match, the first match wins. Put specific patterns before catch-alls.
- Redirects run before the request reaches the worker. They skip static asset serving, ISR and SSR.
Domain-level redirects
This step redirects only requests for one domain. Prefix the source with https://host.
{
"routing": {
"redirects": {
"https://www.example.com/*": "https://example.com/:splat",
"https://old-marketing.com/*": "https://example.com/:splat"
}
}
}The _redirects file accepts the same syntax:
https://www.example.com/* https://example.com/:splat 301Path-only sources apply to every domain on the project. Host-prefixed sources apply only to the named domain.
The source must use https:// and a literal hostname, with no wildcard or port. Add the domain with void domain add before you deploy the rule. A domain awaiting certificate verification starts redirecting once it is active.
Framework _redirects files
The SDK reads _redirects files from supported frameworks. You can also put one in Vite's publicDir.
/old-page /new-page 301
/blog/* /posts/:splat 301Rules in void.config.ts win over file rules. Use 200 for a fallback or 200! for a rewrite. Redirects don't need the ! suffix.