Yii : route config for subdomains

April 29th, 2015 § 0 comments

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
array(
    '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.

Revath S Kumar [RSK]

- Rubyist / JavaScripter - Yeoman Team member - Open source enthusiast - Blogger @ PHPRepo and http://blog.revathskumar.com - Coder @ Whatznear - Google fanboy - jQuery lover

More Posts - Website - Twitter - Facebook - LinkedIn - Pinterest - Google Plus - YouTube

Tagged ,

Comments are closed.