Subdomain With A Route To A Controller

Hello guys.

I made my routes using the domain without a subdomain and works fine.

But now, I need to put a subdomain in frontend module and set routes only for this subdomain.


'urlManager' => [

    'enablePrettyUrl' => true,

    'enableStrictParsing' => true,

    'showScriptName' => false,

    'rules' => [

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

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

        '/' => 'site/index',

        // Example

        '<controller:\w+> => 'subdomain/index',

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



How can I do this?

Another question. How can I do to create another module different to frontend and backend?

If this is possible, I can solve this problem.