[eluser]moodh[/eluser]
I use a standard installation and get subdomains mapped to various controllers without a problem at all:
Index.php example:
Code:
<?php
// Normal app/system paths
// Host address
$host = $_SERVER['HTTP_HOST'];
// Extract eventual subdomain
$subdomain = substr($host, 0, strrpos(substr($host, 0, strrpos($host, '.')), '.'));
// Define subdomain
if($subdomain !== 'www' && $subdomain !== '') {
define('SUBDOMAIN', $subdomain);
} else {
define('SUBDOMAIN', FALSE);
}
// Rest of index.php
?>
Routes.php example:
Code:
<?php
if(SUBDOMAIN === FALSE) {
$route['default_controller'] = "foo";
} else {
$route['default_controller'] = "bar";
$route['what-is-my-subdomain'] = 'this_is_my_sub_domain/' . SUBDOMAIN;
}
?>
Edit: Of course this needs a .htaccess that redirects everything, subdomains or not to the root url without changing it.
Edit2: and you dont need to use the constant SUBDOMAIN, another look at $_SERVER['HTTP_HOST']; still contains the subdomain for usage in your code =)