Netzli Docs

Redirects and rewrites

A file named _redirects at the top of the published folder redirects and rewrites addresses, in Netlify's format. With a build, put it in the folder your framework copies as it is, such as public/ for Vite and Astro or static/ for Hugo.

Each line is a rule: the address, the target and a status, 301 if none is given. Lines starting with # are comments. The first matching rule decides.

_redirects
# Old addresses
/home        /               301
/news/*      /blog/:splat
/tags/:tag   /topics/:tag
/store id=:id  /products/:id  301
/old-shop    /gone.html      410

# Another website's API under your address
/api/*       https://api.example.org/:splat  200

# A single-page app shows index.html for every other address
/*           /index.html     200
  • A * at the end matches the rest of the address, and the target uses it as :splat.
  • A :name matches one part of the address between slashes.
  • A query parameter such as id=:id after the address selects the rule. Visitors' query strings pass on to the target.
  • 301, 302, 303, 307 and 308 redirect. 200 shows the target under the visitor's address. 404 and 410 show the target with that status.
  • A file at the address wins over a rule. To apply the rule anyway, add ! to the status, such as 301!.
  • A rule matches with or without a trailing slash.

A 200 rule whose target is another https:// website forwards the visitor's request there, with its method, query, cookies and body, and shows the answer under your address. The browser needs no CORS headers, and the other website doesn't learn the visitor's address.

Netzli doesn't support conditions such as Country or Role, query strings in targets, or targets starting with http://. Addresses use only letters, digits and - . _ ~ /, so encode anything else, such as ü as %C3%BC.

Netzli checks the file before the site goes live. A line it can't use is skipped and named on the deployment page, and the other rules still go live.