Thanks for the answer.
I was probably not entirely clear with my question. Let me clarify a few points:
?lang=DE is not a part of the incoming query string. Rather, I want Netlify to recognize visitors from Germany and add this query string to the destination URL. And to be fair, Netlify already does this pretty well.
- The query string example I provided (
?click_source=google_ad) is really just an example. It could have a different value, for example ?click_source=blog_article. Furthermore, there could be other query string parameters which we do not know in advance. So I am after passing through ALL query string parameters, just like Netlify does with recent changes for to URLs that contain no query string.
Let’s have a look at my config file:
# netlify.toml
[[redirects]]
from = "/"
to = "https://eu.example.com/?lang=de"
force = true
conditions = { Country = ["DE"] }
[[redirects]]
from = "/"
to = "https://eu.example.com/?lang=fr"
force = true
conditions = { Country = ["FR"] }
In the above example, my website is example.com, hosted on Netlify. If someone visits this URL from Canada, United States, or just about any country except Germany or France, all good, example.com should open just fine.
However, if a visitor comes from Germany or France, they should be forwarded to https://eu.example.com. In addition, eu.example.com supports multiple languages, and language is set via lang parameter. So, I am using Netlify redirects to provide that query string.
With current config, German visitors are sent to https://eu.example.com/?lang=de and French visitors are sent to https://eu.example.com/?lang=fr
It works well except cases when the original URL contained some query string parameters (that I don’t want to lose). Let’s go through examples:
No incoming query string
- A visitor from Germany opens
https://example.com
- They are forwarded to
https://eu.example.com/?lang=de
ALL GOOD
Incoming query string is present
- A visitor from France opens
https://example.com/?foo=bar
- They are forwarded to
https://eu.example.com/?lang=fr
NOT GOOD, because ?foo=bar is lost and never made to the destination website.
So to go back to my question: is it possible to change my config in a way that in the 2nd example the visitor would have been forwarded to https://eu.example.com/?lang=fr&foo=bar instead.
Hope this clarifies things. I understand very well that Netlify is not designed to be a URL forwarding solution (and it’s pretty amazing at things it is designed for!). Yet I’d say it’s also quite close to being a perfect URL forwarding tool and that’s why I am so demanding 