Yii : route config for subdomains

April 29th, 2015 § 0 comments § permalink

Recently I was setting up a subdomain for a existing project, I needed to configure a different root route for the it. First I tried to do it with htaccess but I failed. Then I found a solution after some googling.

// protected/config/main.php
    'urlManager' => array(
      'urlFormat' => 'path',
      'showScriptName' => false,
      'caseSensitive' => true,
      'rules' => array(
        'home' => 'site/index',
        'http://about.site.dev/' => 'about/index',

This will result in two different root route for site.dev and about.site.dev. I you know a better solution please let me know.