Answer the question
In order to leave comments, you need to log in
How to make a redirect to the Russian and English versions of the site?
There are two directories on the hosting: ru and en, for Russian-speaking and English-speaking users, respectively. How to make it so that when entering from Russian, Belarusian, Ukrainian and Kazakh ip addresses, the directory is thrown to ru, and from the rest - to en?
Answer the question
In order to leave comments, you need to log in
Why by IP?! You can also find out what language the user is using and already do a redirect. This squalor to do on IP. Here is your solution
put a database of ip addresses (or from a third-party service, but this is very long) and, depending on - transfer where necessary
Among other things, the browser itself usually gives out a set of languages preferred by the user, an almost ready-made solution + a list of "Russian-speaking" languages \u200b\u200bis here . But if you really want it by IP and / or the browser did not send a set of preferred languages \u200b\u200b(* in this case I would just transfer it to EN), then you can use a ready-made solution for PHP .
The correct solution is to use the information from the headers about the language being used.
If it is not possible to determine the language from the data from the browser, you should rely on the definition through the Ip address . Just rely on the country code. If not found, then always open the English version.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question