How to configure modules as subdomain in yii2 application.

Well, I have created a modules named sale in yii2. And I have also created a subdomain called sale on my control panel and put url as Here is my module config

'modules' => [

        'sale' => [

            'class' => 'frontend\modules\blog\Module',

            ## To load default controller of sale module

            //'defaultRoute' => 'site', // 






'urlManager' => [

           'class' => 'yii\web\UrlManager',

           // Disable index.php

           'showScriptName' => false,

           // Disable r= routes and apecial chars from url

           'enablePrettyUrl' => true,

           // Rules

           'rules' => [

                '' => 'sale/default/index',

                // your rules go here        

                '<controller:\w+>/<id:\d+>' => '<controller>/view',

                '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',                

                '<controller:\w+>/<action:\w+>' => '<controller>/<action>',


The main for this is to share the session data in all the application within the domain. I have used same layouts in all modules and controllers. So it seems to use same homeUrl to all application.

The problem is that while I access other url its not pointing to main application url.

Is there any way to configure this problem.

Thanks in advanced.

<module>/<controller>etc - I think.