Answer the question
In order to leave comments, you need to log in
How is localization by subdomains implemented?
Good evening everyone.
Please share how localization is implemented using subdomains?
For example, for the Russian language - ru.site.com, English - en.site.com and so on.
I can't find proper information. Thanks in advance)
Answer the question
In order to leave comments, you need to log in
Something like this:
A single Document Root is installed for all subdomains, and then in the application:
$url_array = explode('.', parse_url($request->url(), PHP_URL_HOST));
$subdomain = $url_array[0];
...
$languages = ['en','de'];
if (in_array($langcode, $languages)){
App::setLocale($langcode);
}
For example:
When entering the main domain, the language is determined in the middleware:
By this value, the middleware goes to The database looks to see if there is such a language in the system, and puts the value, for example, in a cookie/session and/or redirects to a subdomain with the desired location, then displays already localized content
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question