Redirect by browser language

I can confirm, that a simple lang redirect form root is not working:
/ /de/ 301 Language=de
/ /es/ 301 Language=es
/ /en/ 301

This ALWAYS redirects to /en and never matches the languages.
Any idea ?

Hi, I think you asked about this in another thread already, and I asked you for more info there :wink:

Hi @futuregerald or @Dennis ! I was wondering if it would be possible to do something like:
from = “/*”
to = “/fr/maintenance”
status = 302
force = true
conditions = {Language = [“fr”]} /

from = “/*”
to = “/nl/maintenance”
status = 302
force = true
conditions = {Language = [“!fr”]} // All languages except fr

But I guess these above would be conflicting? (at least it didn’t work)

Using a bang (!) is not supported. However, since our system parses redirect rules from top to bottom (cascading), the second redirect rule doesn’t have to have the Language conditions since any ‘fr’ requests will never reach that redirect. Essentially, the more specific rules (like that ‘fr’ language redirect) should be on the top of the file. Let me know if that makes sense.

The forum software is asking me

Oh yes, I’m absolutely positive that I want to revive this topic. The language-based redirect works if only one language is present in the Accept-Language header and only if no quality value is given. This feature is useless in its current form and only causes confusion. Even a vanilla installation of Chrome sends a header that cannot be interpreted by your redirect engine: en-US,en;q=0.9. I think you should either complete this feature or admit that you’re not going to implement it and simply remove it from the documentation.

Hey @revl,

Yeah, Country redirects are much more widely… functional? compared to Lang redirects at this present time. However, a lot of work is going in to this area so stay tuned! :slight_smile:

1 Like

That’s OK. Thanks for the update. We’ll wait, impatiently. To be clear, country redirects are a poor substitute for language redirects. Canadians from Quebec can attest to that.

Hi @Dennis Hi @federicovezzoli you manage to successfully redirect based on the country, i’m tryin to achieve it, but it doesn’t seem to work.
I have to domain setup on as primary and as domain alias.
I want to redirect switzerland users to the .ch domain.
This is my toml
from = “/*”
to = “
status = 302
force = true
conditions = {Country = [“ch”, “CH”]}

Any clue?

Hey there!

I can’t see that particular rule for the deployed site, only rules for /de and /de/:splat.

Can you confirm what you’re trying to achieve?

Still having the issue
Any help?
Dis someone solve this?

Hey! Maybe you missed my last post:

Hi thx a lot for the reply.
I want people in switzerland to be redirected to the .ch domain. But I ended up having infinite redirects.
That is why you don’t see it.

[[redirects]] from = “/*” to = “ 1” status = 302 force = true conditions = {Country = [“ch”, “CH”]}

Both .ch and .com are set on the same netlify project. The .ch works the same as the .com, but can’t seem to redirect users based if they are from switzerland.

Any help would make my client happy.

Ah, the rule might infinitely loop because /* will also try and redirect the .ch site using the rule!

You’ll need to specify the full path in the from condition:

from = "*"

thx for the reply.
I’ll try that.

While I’m happy @waw-webcontents found help here, this topic is actually about redirects based on browser language NOT working on Netlify.

Do we have news here by any chance, @Pie?

Depends what you’re trying to do, @oskar, and what you expect – for language redirects, if the browser observes a single language (without quality) then things are fab! It’s when quality is at play where things get a little spicy.

The ‘blocking’ works are ongoing, as part of a larger project. So, unfortunately – in short – nothing outward to report just yet!

@Pie Wondering if there is any update to this?

Work is still ongoing. Rest assured, we’ll let y’all know once progress is made!

Hi @Pie, thanks for the reply. Is there any timeline for this?
Our high-profile customer would highly appreciate that feature :slight_smile:


Hey @henry1,

Unfortunately, there’s no timeline – we’d hate to make false promises! Stay tuned :slight_smile: