J
J
jekahm2015-12-30 16:42:33
Yii
jekahm, 2015-12-30 16:42:33

How to organize multilingualism in Yii2 using subdomains?

Good day!
I came across an article with the implementation of multilingualism in Yii2 habrahabr.ru/post/226931 . I would like to know if it is possible to implement something similar, but with the use of subdomains (respectively, without actually creating them)? That is, the links should look like this: en.example.com/mypage.
Thanks in advance for your help!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey, 2015-12-30
@VladimirAndreev

Well, set up a rewrite in the web server...

A
Anton, 2016-08-18
@conturov

In DNS, write a record like this:
@ A 123.123.123.123
Thus, the server will accept any subdomain
Then create the necessary WWW domains as aliases to this domain: en.domain.com, ua.domain.com, de.domain.com
So we say the server that when requesting subdomains en, ua, de, you need to show the main site.
Then, in Yii itself, catch the URL and parse it, assigning the current language.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question