Language and 404 redirects don't work

What I can read in the documentation doesn’t work in production or netlify dev environment.

We are developing a multi-language website and I only find problems with redirects.

I cannot filter by language. This issue has open threads in the community since September/October 2019. We are at July 2020 and the problems continue.

My netlify.toml

[[redirects]]
from = "/"
to = "/es"
status = 302
force = true
conditions = {Language = ["es"]}

[[redirects]]
from = "/"
to = "/en"
status = 302

This works locally for Safari and Chrome, but in production it only works in Safari. Apparently in Chrome if you have multiple languages ​​configured this redirect does not work and 80% of users use Chrome. By default my chrome browser has two languages: “es” and “es-ES”.

If I filter by country redirects works:

[[redirects]]
from = "/"
to = "/es"
status = 302
force = true
conditions = {Country = ["ES"]}

[[redirects]]
from = "/"
to = "/en"
status = 302

Now it works in all browsers but new problems appear. The EN version of the web is always loaded locally, because netlify-cli does not detect any country in the call locally. And another problem is that there are many countries where Spanish is spoken. Do I have to enter them all manually? This is crazy.

For language 404 redirects I have problems that look like “X files”.

With the same configuration, one site works for me and another does not.

I have set up a demo site: https://kind-kilby-b7673b.netlify.app/

This is the netlify.toml setting

[[redirects]]
from = "/"
to = "/es"
status = 302
force = true
conditions = {Country = ["ES"]}

[[redirects]]
from = "/"
to = "/en"
force = true
status = 302

[[redirects]]
from = "/es/*"
to = "/es/404/"
status = 404

[[redirects]]
from = "/en/*"
to = "/en/404/"
status = 404

Everything seems to be working properly.
When a 404 occurs, the redirection takes the user to the 404 error page corresponding to each language.

Now I have another site where we are working for a client.

The configuration of the redirects is exactly the same.

On this site Chrome does not load 404 by language and it gives an error in the redirection. Safari works correctly. These kinds of mistakes are a punishment. We chose Netlify precisely so as not to worry about these things.

This is the API Site ID: 7f6f22aa-bd63-4043-882b-334261daa271

I hope you can review what happens because nothing works as we hope. We have wasted many hours with this and we are quite disappointed. Especially knowing that these problems have existed since the end of 2019.

We wait for your answer.

Thank you.

hiya @existo and sorry to be slow to get back to you! Our language redirects are pretty picky - Chrome’s language spec doesn’t match what we’re expecting, as you’ve seen. You’d do better to go with country-based redirects for now (I know, there are people in Spain and Mexico who don’t speak español, and people in the US who do. Still, this will be the best you can do today without using a function and checking the Accept-Language header yourself - which if you choose to do it, will work well if you set a cookie for your site called nf_lang that you set appropriately to a language code; they won’t need the function again, but the language redirect will then work correctly, as long as they don’t block the cookie!).

Country redirects work reliably in every browser (save people who are using VPN’s to intentionally mask their country of origin, but that is a problem for all services).

We are working on a major overhaul of our redirects that should hopefully improve the functionality here, and I’ll follow up in this thread when it is available to use.

1 Like