Headers
A file named _headers next to _redirects sets response headers, in Netlify's format: a path on its own line, then its headers, each indented on its own line.
/*
X-Frame-Options: DENY
Referrer-Policy: strict-origin-when-cross-origin
Content-Security-Policy: default-src 'self'
/assets/*
Cache-Control: public, max-age=31536000, immutable
- A
*matches any characters, slashes included. A:namematches one part of the path between slashes. The query string doesn't count. - When several matching paths set the same header, the last one in the file wins.
- The headers go on your site's files, its
404page included, but not on redirects or on answers from another website. - Values are sent exactly as written. Only
\and{$aren't allowed. - Netzli refuses
Set-Cookie, Netlify'sBasic-Authand the headers its web server sets itself, such asContent-Length,DateandServer. - Netzli already sends
X-Content-Type-Options: nosniff.
As with _redirects, a line Netzli can't use is skipped and named on the deployment page.