How to map domains to modules

I am rebuilding a company’s three websites and combine them into one Yii application. For SEO and historical reasons I have to keep the three original domain names - each one has a different focus (training, sales and general) and slightly different look and feel. They need to be on a single application because they share a common backend.

So say the three domain urls are, and I want to match them onto three modules, say abc, def and ghi. There will also be another module called admin.

How do I do this without explicitly putting the module in the url? For example, should load module/controller/view abc/default/index. So the module should not appear in the url.

The only possible exception to this would be if would load say module ghi eg: - although I would still prefer that the appropriate domain is displayed - in this case

I would appreciate any input on this.

This sounds similar to something I am implementing. I have a single application, and I am using urlManager to map subdomains (as opposed to TLDs) to modules.

eg. is the parent application would show the same as would show the same as

This is fairly easily achieved with the urlManager rules in the config/main.php file:

return array(








        '' => 'module1/',

        '<_c:\w+>' => 'module1/<_c>',  // this MIGHT be redundant - anyone else care to comment?

        '<_c:\w+>/<_a:\w+>/*' => 'module1/<_c>/<_a>',  // this MIGHT also be redundant.

        '' => 'module2/',

        '<_c:\w+>' => 'module2/<_c>',

        '<_c:\w+>/<_a:\w+>/*' => 'module2/<_c>/<_a>',








You could TRY something similar, except in place of

'' => 'module1/',

you could put

'' => 'abc/', // or whatever name you gave the module for this domain

You would of course need to have each domain pointing to the application’s root directory (my host allows this through parked domains).

Whether this approach would work I am not able to tell you, but it might be worth a try. Someone with a little more experience might be able to shed some light…

Many thanks for this.

This is in place - now to test the solution on the server. I’ll keep you posted.