Hi Federico and sorry to hear about the trouble! First off, I don’t see that redirect on that site - there are about 40 non-language 301 redirects like this:
"/prodotti/ev-smart-2/" to "/prodotti"
so, either you removed it, or you are not deploying what you think you are.
Next up, with that configuration, you’ll redirect ONLY the main page and ONLY if you DON’T have an index.html so I think that is probably not what you want If you want all URLs to redirect regardless of what content is on the english language site, you want something more like this:
Hi fool! thanks for the reply.
I had the rules inside the _redirects file.
Now I’ve placed your examples inside the netlify.toml file but during build it gives me this error:
Invalid netlify.toml file: Error while decoding file /opt/build/repo/netlify.toml: Near line 1 (last key parsed ‘’): bare keys cannot contain ‘/’
I’m a bit confused now in which syntax is correct for the netlify.toml file, I’ve also tried:
[[redirects]] from = "/"* to = “https://www.evlaser.it/:splat” status = 302 force = true conditions = {Language = “it”}
with no luck, I get this error during the build: Invalid netlify.toml file: Error while decoding file /opt/build/repo/netlify.toml: toml: cannot load TOML value of type string into a Go slice
The examples that @fool mentioned is for the _redirects file. Those examples will need to be converted to the structured format if you want to use them in your netlify.toml file.
This is how the redirect should look like:
[[redirects]]
from = "/*"
to = “https://www.evlaser.it/:splat”
status = 302
force = true
conditions = {Language = [“it”]}
Hi @federicovezzoli can you please provide a link to the deploy that you are testing and the URL that you are testing with? Also does your browser have multiple languages set? Can you test with sending a single language and let me know if that works? Note that I don’t believe people should limit the number of languages, this is for debugging purposes.
Hi @futuregerald or @Dennis ! I was wondering if it would be possible to do something like:
[[redirects]]
from = “/*”
to = “/fr/maintenance”
status = 302
force = true
conditions = {Language = [“fr”]} /
[[redirects]]
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.
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.
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!
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 www.w-architectures.com as primary and www.w-architectures.ch as domain alias.
I want to redirect switzerland users to the .ch domain.
This is my toml
[[redirects]]
from = “/*”
to = “https://www.w-architectures.ch/:splat”
status = 302
force = true
conditions = {Country = [“ch”, “CH”]}
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 = “https://www.w-architectures.ch/:splat 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.