eduardo.lopes
eduardo.lopes

Reputation: 512

Yii2 - Subdomain to module routing

I googled and searched here, but didnt find a solution... All that I found was subdomain to controller route... But thats not what I´m looking for...

So... here we go.

I have 2 subdomains:

sub-domain-a.site.com
sub-domain-b.site.com

And I have 2 modules:

module-a
module-b

I want Yii2 to redirect all requests to sub-domain-a to module-a and all requests to sub-domain-b to module-b...

so, if I have a controller in module-a, I just call:

sub-domain-a.site.com/controller-a-1

instead of

www.site.com/module-a/controller-a-1

same thing with sub-domain-b and module-b...

How can I accomplish this with Yii??

Thx!!

Upvotes: 0

Views: 840

Answers (1)

Vilk
Vilk

Reputation: 162

in config:

[
'components' => [
    'urlManager' => [
        'enablePrettyUrl' => true,
        'showScriptName' => false,
        'enableStrictParsing' => false,
        'rules' => [
            'sub-domain-a.site.com/controller-a-1' => 'module-a/controller-a-1',
        ],
    ],
],

]

Upvotes: 0

Related Questions