I’m a bit confused on what the recommended http status code for redirecting a netlify subdomain to a site’s primary custom domain.
In the Domain Management section of the site’s settings dashboard, there’s an example _redirects file which uses a 301.
However, in the docs for netlify.toml, the example given for the same use case uses a 200.
Which is the recommended code? Does it matter based on whether the rule is in a _redirects vs a netlify.toml file?
I have read the status code docs and understand there’s different behavior depending on which code gets used, I’m just curious as to what the recommended approach is for this specific use case.
A 200 is a rewrite or a proxy rule (cf Redirects and rewrites | Netlify Docs), which if used in that context does the opposite of what you want - it shows your site (mydomain.com) content at the netlify hostname (https://yoursite.netlify.com), instead of telling the browser “no, this is not the canonical URL, instead go over to https://mydomain.com” which is what a 301 redirect would do.
Those docs with the 200 example are buggy and have been live for a year and a half and you’re the first person to notice ! Thank you for calling it out; I’m fixing it now.
Doesn’t matter if it goes in _redirects or netlify.toml; both are parsed after deploy and applied to your site.