php - Multiple Domains in Yii2 -
i have project yii2.
i have more domain project.
i need login user other domain.
the main domain: domain.com login in domain worked
other domain saved in db: domain1.com , domain2.com , domain3.com ,... problem list
domain list saved in database , park in directadmin
params file:
return [ //todo: change line when upload application on domain 'domain' => 'domain.com', ];
web file:
$params = require(__dir__ . '/params.php'); $config = [ 'id' => 'projectname', 'name'=>'projectname', 'basepath' => dirname(__dir__), 'bootstrap' => ['log', 'app\components\aliases'], 'language' => 'en_us', 'components' => [ 'request' => [ 'baseurl'=> '', // !!! insert secret key in following (if empty) - required cookie validation 'cookievalidationkey' => 'n+!@l_i&#r^s!#&$j', 'csrfcookie' => [ 'name' => '_csrf', 'path' => '/', 'domain' => ".".$params['domain'], ], ], 'cache' => [ 'class' => 'yii\caching\filecache', ], 'user' => [ 'identityclass' => 'app\models\user', 'class' => 'app\components\user', 'enableautologin' => true, 'loginurl' => ['user/login'], 'identitycookie' => [ 'name' => '_identity', 'path' => '/', 'domain' => ".".$params['domain'], ], ], 'authmanager' => [ 'class' => 'app\components\phprbac', ], 'session' => [ 'class' => 'yii\web\dbsession', 'cookieparams' => [ 'path' => '/', 'domain' => ".".$params['domain'], ], 'timeout' => 3600, ], 'view' => [ 'theme' => [ 'basepath' => '@app/themes/system', 'baseurl' => '@web/themes/system', 'pathmap' => [ '@app/views' => '@app/themes/system', '@app/widgets' => '@app/themes/system/widgets', ], ], ], 'urlmanager' => [ 'enableprettyurl' => true, 'showscriptname' => false, 'cache' => 'cache', 'rules' => [ '<action:(about)>'=>'site/<action>', 'panel/<controller>/<action>'=>'<controller>/admin-blog-<action>', 'admin/<controller>/<action>'=>'<controller>/admin-<action>', 'blog/create/<domain>' => 'blog/create', /* home page */ 'domain.com' => 'site/index', /* blog sub domain */ 'http://<domain:(www.)*\w+>.domain.com/' => 'blogs/index', 'http://<domain:(www.)*\w+>.domain.com/profile' => 'profile/index', 'http://<domain:(www.)*\w+>.domain.com/<action>' => 'blogs/<action>', /* blog domain */ 'http://<domain:(www.)*[^!domain]\w+(.)\w{1,4}+>' => 'blogs/index', 'http://<domain:(www.)*[^!domain]\w+(.)\w{1,4}+>/profile' => 'profile/index', 'http://<domain:(www.)*[^!domain]\w+(.)\w{1,4}+>/<action>' => 'blogs/<action>', ] ], 'db' => require(__dir__ . '/db.php'), ], 'params' => $params, ];
Comments
Post a Comment