Skip to content
Built with

Redirects ​

Build & Deploy

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.

json
{
  "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 with to and optional status. Supported statuses: 301, 302, 303, 307, 308.
  • :splat in the destination is replaced with the portion of the path matched by * in the source pattern.
  • Destination query strings merge into the Location header. 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.

json
{
  "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  301

Path-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.

text
/old-page  /new-page     301
/blog/*    /posts/:splat 301

Rules in void.config.ts win over file rules. Use 200 for a fallback or 200! for a rewrite. Redirects don't need the ! suffix.

Next steps ​

implemented.stream AI