I was going to create a topic for my issue but I saw this post already exists so I hope OP doesn’t mind if I pile on.
I’ve pretty much abandoned trying to redirect in my .toml file and now attempting with _redirects. I’d appreciate any feedback since I’m experiencing the OP’s issue, I think.
My goal is simple. I want to redirect from http://dev--ag-poc.netlify.com to http://dev--ag-poc.netlify.com/northamerica/en for most visitors with one exception.
If the user is using Spanish (leaning towards Latin American), then redirect to http://dev--ag-poc.netlify.com/northamerica/es.
Were this to work I’d be able to add additional language re-directs that I want to support.
I learned 2 things from other posts:
with conditions be specific first, generalize second
use 301 instead of 302 (used w/gated content for example c.f. blog post)
So my rules are: / /northamerica/es 301 Language=es-419,es-CL,es-AR,es / /northamerica/en 301
I’m testing with MacOS with Spanish language settings, Chrome and FF are installed with Spanish language packs as default (latter is Chilean and Argentinian). Wouldn’t you know, Chrome and FF both fail and go to the English path while Safari works correctly.
I had also tried with / /northamerica/es 301 Language=es but it didn’t work, hence the granular attempt with the region codes.
Thanks for reaching out and providing those details. We have issues filed around the odd behavior with GoeIP redirects that our team is looking in to. We’ll update here once we have more information.
@derhaeuptling.com you actually mentioned this issue in 3 separate threads. I responded to you asking for more details in one of them. Please reply there. It’s much easier to debug in a single thread then across multiple threads. Thanks!
I have the exact same issue, it’s working on Safari but not on Chrome & Firefox.
My browsers are set to French, but it’s automatically pointing to English on Chrome/Firefox.
I checked the headers in the browsers & I got same result as mentionned earlier.
Any news on this matter? Is it linked to the Netlify email we just received mentionning something should be fixed on April 7th?
My _redirects file is :
# Redirect users with french language preference from / to /fr
/ /fr/ 301! Language=fr
/ /fr/ 301! Language=fr-BE
/ /fr/ 301! Language=fr-CA
/ /fr/ 301! Language=fr-CH
/ /fr/ 301! Language=fr-FR
/ /fr/ 301! Language=fr-LU
/ /fr/ 301! Language=fr-MC
/ /en/ 301
Unfortunately, those redirects are not for “real” language codes - they are instead locales. I know, your browser sets those automatically, but our system doesn’t handle them We only handle plain fr correctly at the moment.
No change on the open feature request to make that work better though I can tell you the team developing our next generation redirects engine is doing great and fast work, so we can see a light at the end of the tunnel in that implementation and will follow up here when it is available for general use!
Thanks for your answer & the follow-up.
Actually, I also set up a nf_lang cookie including the language from the browser.
Can’t we play with this to get around this limitation ?
I don’t know of any workarounds for getting the Accept-Language locales to work consistently when sending multiple locals, but you can set your own nf_lang cookie and then use your own redirects based on the language set there. This will work since the nf_lang cookie takes precedence over the language that the browser sends in the Accept-Language header.