Using Netlify, can I add custom HTTP headers to a path on one domain but not another?
e.g. if I wanted my-domain.com to return a 301 with headers different to the headers returned by www.my-domain.com.
@talves has explained below why my initial approach (quoted) won’t work.
Given the below in
netlify.toml
, I expect to see my customCache-Control
header (and NOT see theLink
header) when I runcurl -I http://hello-yoga.co.uk
but that's not happening.What am I doing wrong?
[[headers]] for = "/" [headers.values] Link = "</yoga-people.svg>; rel=preload; as=image" [[redirects]] from = "http://hello-yoga.co.uk/*" to = "https://www.hello-yoga.co.uk/:splat" status = 301 force = true headers = {Cache-Control = "public, max-age=2592000"}
Result:
$ curl -I http://hello-yoga.co.uk HTTP/1.1 301 Moved Permanently Cache-Control: public, max-age=0, must-revalidate Link: </yoga-people.svg>; rel=preload; as=image Location: https://www.hello-yoga.co.uk/
Netlify support confirmed the only way to do this is with two Netlify apps: