What should I do so that each stores can be accessed as a subdomain, such as http://sample1.mysampleproject.com? Can this be done via urlManager? Or is there a better way to handle my stores?
where that class adds url rules according to domains:
/**
* Manage domains and subdomains
*/
class DomainManager
{
public static function route()
{
//check if domain is valid/active and set it to Yii::app()->params['store_domain'] + some other things like preloaded store AR
...
//add url rules with domain names
$urls = array(
// your main site domain from config
'http://' . Yii::app()->params['root_domain'] . '/<controller:\w+>/<id:\d+>'=>'root/<controller>/view',
// store domain/subdomain
'http://' . Yii::app()->params['store_domain'] . '/<controller:\w+>/<id:\d+>'=>'shop/<controller>/view',
// all other rules
...
);
Yii::app()->getUrlManager()->addRules($urls);
}
}
This is a bit simplified but I hope you get the concept.
Thanks to all your answers. All the suggested solutions refers to one thing: Parameterizing Hostnames. I was on that page yesterday and I’m positive that I’ve read the whole page…not sure how I missed that one. Anyway, thanks again. +1 to you all.