How to disable automatically redirects

I’m trying to disable automatically redirects from the secondary domain to the primary domain but it doesn’t work.

Here is my _redirects file:

https://odontologiagallicchio.com.br/* https://odontologiagallicchio.com.br/
https://www.odontologiagallicchio.com.br/* https://www.odontologiagallicchio.com.br/

Hi there,

You cannot change the way that feature works for the PRIMARY custom domain - we will always redirect from www<->bare domain depending on your configuration (will end up at the one labelled as “primary custom domain” in our UI). Doing this is good for SEO - otherwise you have duplicate content on the internet at 2 URL’s. Could you elaborate on why you want to do this?

There are ways to work around it - such as setting a “bogus” custom domain, and then we will do NO redirection between ADDITIONAL domains, which are labelled in our UI as “domain aliases”.

I have www.example.com set as the primary domain and example.com (with automatic redirects) listed below). I have tried your workaround by adding the apex domain (example.com) as a domain alias, but I cannot get any redirects to override the automatic ones. Is this workaround still possible?

Setting your bare domain as a domain alias also requires that you set a different domain as your primary custom domain. Could you do that as well and let me know if that works?

Thank you Dennis, that worked! So the solution was to set a dummy domain like netlify-redirect-workaround.example.com as the primary domain (instead of example.com or www.example.com) and using the following _redirects file:

/.well-known/* /.well-known-apex/:splat 200  # this will match before the generic redirect below
http://example.com/* https://www.example.com/:splat 301!
https://example.com/* https://www.example.com/:splat 301!