Redirect File Formats
Each build writes redirect rules into files at the output root. Their formats depend on which web server or hosting product reads them, so this page describes both — and the one line that only works on Caddy.
The three files
_redirects(output root) — Netlify-format rules, one per line:old-path new-path status-code. Written from your redirects settings (sky redirects with the status code you chose per rule)._redirects.caddy(output root) — the same slug redirects expressed in Caddy’s nativeredirdirective syntax, with a header comment telling you to include the snippet in your Caddyfile site block. Generated only when your Site URL is set.- The canonical-domain block appended into
_redirectswhen a Site URL is configured: a single rule that 301s the www/bare alternate host to your canonical host, path intact.
What the rules are
- Slug redirects — your redirect rules (old slug/new slug per language/type), emitted only when the old URL no longer resolves to live content; a redirect you configure against an address that is still a live page/post is suppressed so established URLs stay reachable.
- Prefix-change redirects — an automatic post-prefix change (e.g. the blog prefix) writes the old
blog/<slug>/ …paths to the new structure. - Status codes — 301, 302, or 307 as chosen per rule; 301 when not set.
Caddy-only syntax note
The canonical-domain line uses Caddy’s redir external-force marker (301!). A strictly-Netlify-compatible parser treats that trailing character as part of the target; when publishing the output tree to a host other than Caddy, review that block. Slug redirect (Netlify-format) lines themselves are plain path pairs that wide host support handles.
What’s deliberately not in the files
Pattern redirects (* wildcards with $1 substitutions) are never written into these files — the simple formats can’t express them safely. Pattern redirects require rules implemented in your reverse proxy configuration.
Referencing the Caddy snippet
# in your Caddyfile site block:
import /var/www/chinaski1/output/_redirects.caddy (Include path as the file’s own header comment directs — the exact include style is the snippet’s own header note.)