Language redirect only working in Safari

I added the following to my _redirects file to redirect user with french language set as prefered in their browser to the French homepage:

/ /fr 302  Language=fr,fr-fr,fr-ca

It does work on Safari, but not on Chrome or Firefox. Anything I’m doing wrong?

In action: https://deploy-preview-75--boralex.netlify.com/

1 Like

Hi @regisphilibert,

I just tested from the latest version of Chrome and the redirect is working for me:

Can you copy the full request you were sending so I can see what the differences were?

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. :slight_smile:

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.

Chrome result :frowning: :

Safari result :slight_smile: :

Hi,

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.

Hi @futuregerald , this thread is about prefered language redirect.

But I do have one about GeoIP: Geo redir breaks every 1/2hour or so

Always great to read you!

Sorry && thanks @regisphilibert . I love seeing you here in our community. :smile:

1 Like

I can confirm what @vict-r say.
We have the exact same issue, also that it is only working in Safari.

We tried with:
/ /de/ 301! Language=de-DE,de
/ /es/ 301! Language=es
/ /en/ 301

@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!

Hi !

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 :frowning: 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!

Hi @fool,

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 ?

Thanks!

Hi,

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.

1 Like