Answer the question
In order to leave comments, you need to log in
Yii2. How to create a subdomain during registration?
nginx web server. It is necessary to implement the creation of a subdomain when registering a user (for example, the user Vasya specified the domain vasya during registration; as a result, his profile should be available at vasya.example.com).
Tell me how it's done and how to implement it correctly?
Answer the question
In order to leave comments, you need to log in
There is a router in Yii2, everything is fine (comment to the previous answer).
We put alias as suggested by xmoonlight (you can on a separate part of the application if you use the advanced template).
In the router ($config->components):
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
// остальной конфиг роутера
'http://<login:[\w\-]+>.example.com/<action:\w+>' => 'profile/<action>', // контроллер ProfileController должен существовать, и в нем надо бы реализовать behavior (или метод init) на проверку существования пользователя с таким логином
],
],
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question