Redirect by country issue

Hi !

I am developing this website :

I’d like the website to be in english by default, except for users based in France. I created a folder /fr that
contains the website translated in french. I’ve followed netlify’s documentation about redirects, and i’ve read related topics but i can’t make the redirection works.
Note that i am currently based in France, which means that i should be redirected to Tristan Berger | Développeur Web if everything works correctly.

Here is what my netlify.toml looks like, i’ve tried different configuration but none of them worked.

from = “/”
to = “/fr/”
status = 302
force = false
conditions = {Country = [“fr”], Language = [“fr”]}

I’m quite new to web development, I’m sure i’m missing something or doing something wrong, do you know how can i fix that ?

Thanks !

hi there, @Tuss :wave:

Welcome to the Netlify Forums! Glad you found us :slight_smile: Before we dig in, did you see this blog post on country redirects? It walks through how to set these up, step-by-step:

I suggest walking through the blog post and following the implementation. Additionally, another great resource is our redirect support guide:

If you are still facing difficulties after this, please respond in this thread and we will continue assisting you!

1 Like

Hi @hillary , thanks for you reply.

Actually i’ve followed these posts, but i couldn’t find a way to solve my problem. But i found this topic : Language-based redirect only works when 1 browser language set - #24 by Leksat

I think i’m getting the same issue, it’s a problem coming from the number of accept-language of the browser. Thus i tried to removed the language condition and keep only the country one :

from = “/”
to = “/fr/”
status = 302
force = true
conditions = {Country = “fr”}

And it turns out to work as expected !
For anyone facing the same kind of issue, note that i also had to use force = true, because you cannot shadow a URL that actually exists within the site. ( see Rewrites and proxies | Netlify Docs )

Hey there, @Tuss :wave:

From the sounds of “work as expected”, it sounds like you found a solution! Thanks for letting us know. If anything else comes up, don’t hesitate to follow up here.

Happy building :netliconfetti: