Add subdomain based rules to urlManager


It would be great to be able to specify subdomain in the rules of urlManager so we can say that a route should be used only if subdomain match a regex or a string ( 'subdomain' => 'www' or 'subdomain' => '/.+/' )

It will give us the ability to build subdomain account based app very quickly.



Could you show some practical use cases for this feature? Would these rules only be used for parsing requests, or are they also used for creating URLs?

One of the goal is to have two "root" routes that redirect to homepage if subdomain is www or account page if subdomain != www

Then in the account controller I can check if account exist etc…

As it’s a subdomain, a call to CHtml::link() on won’t change the host part of the URL so the link will stay internal to the current subdomain.