Hi,
I had similar problem.
My application has few modules and base part with components, extensions and models for all modules.
My application handle domain in index.php.
Its not too pretty solution but I want load separated config per module and my modules has similar url rules.
My index.php file
$yii=dirname(__FILE__).'/../yii-1.1.0.r1700/yii.php';
defined('YII_DEBUG') or define('YII_DEBUG',true);
require_once($yii);
function getDomainName() {
$http = ($secure = (isset($_SERVER['HTTPS']) && !strcasecmp($_SERVER['HTTPS'],'on'))) ? 'https' : 'http';
if (isset($_SERVER['HTTP_HOST'])) {
$hostInfo=$http.'://'.$_SERVER['HTTP_HOST'];
} else {
$hostInfo=$http.'://'.$_SERVER['SERVER_NAME'];
$port=$_SERVER['SERVER_PORT'];
if (($port!=80 && !$secure) || ($port!=443 && $secure))
$hostInfo.=':'.$port;
}
$matches = array();
preg_match("/^(?<protocol>(http|https):\/\/)(?<www>(www\.|))((?<domain>.+\.[a-z]+))$/", $hostInfo, $matches);
return trim($matches['domain']);
}
switch (getDomainName()) {
case 'subdomain1.pl':
$config = 'subdomain1';
break;
default:
exit;
break;
}
Yii::createWebApplication(dirname(__FILE__).'/protected/config/'.$config.'.php')->run();
function getDomainName() based on http://www.yiiframework.com/doc/cookbook/55/
and I have main config file
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'import'=>array(
'application.models.*',
'application.components.*',
),
'components'=>array(
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=> false,
),
),
'params'=>array(),
);
and configs for all subdomains (one per subdomain)
$main = include 'main.php';
$hc = array(
'name'=>'subdomain1',
'defaultController'=>'index',
'modules'=>array(
'subdomain1'=>array(
'layout'=>'subdomain1',
'defaultController'=>'index',
),
),
'components'=>array(
'urlManager'=>array(
.....
),
),
),
'params'=>array(),
);
return CMap::mergeArray($main, $hc);
Modules in my application are not exactly modules but separated application with one common part.