I am making a simple landing page that uses English as its primary language (the main version is set as the homepage). However, if we detect that a visitor has a Polish browser, we want to redirect them to the Polish version of the site.
I tried a few solutions from the forum, but they didn’t work - the last one I tried was:
Hi @Kacper_Bieda as you see in image language request returns string in format "en-gb"(on my computer) and your condition contain only two letters. IMO you can use RegEx or slice to compare these first two letters. Something like this
It’s working now, but just in case - when I’ve pasted it in project settings custom code the website was refreshing all the time.
Heading to solution:
Code from you works perfectly fine! Thanks.
It was working all the time, turned out that from some reason it treats my browser (which is in Polish) as English, but on every other device with Polish language the redirection is working perfectly fine.
To make the website stop refreshing, I had to put it back to before </ body> tag on the homepage custom code.