Answer the question
In order to leave comments, you need to log in
How to implement subdomain routing in Yii?
The essence is as follows:
There are three modules:
backend
promo
mobile
The mobile module opens a specific site by the GET parameter "link"
I want to make this parameter (link) a subdomain, i.e., so that the link test.example.com opens example.com/mobile /default/index/link/test etc ( test.example.com/profile -> example.com/mobile/profile/index/link/test ), but backend and promo continued to work with standard yii/
At the moment, the following decision was made in the config:
'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => false,
'rules' => array(
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'http://www.example.com' => '/',
'http://<link:\w+>.example.com' => 'mobile/default/index/',
'http://<link:\w+>.example.com/<controller:\w+>/<action:\w+>/<id:\d+>' => 'mobile/<controller>/<action>',
'http://<link:\w+>.example.com/<controller:\w+>/<action:\w+>' => 'mobile/<controller>/<action>',
'http://<link:\w+>.example.com/<controller:\w+>' => 'mobile/<controller>/index',
'http://<link:\w+>.example.com/mobile/<controller:\w+>/<action:\w+>' => 'mobile/<controller>/<action>',
')
$this->createUrl('/mobile/profile/index')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question