I am soon to redevelop a site and I am wondering what the best practice is for routing CodeIgniter for subdomains. My site will have two "sections", a normal user section and a business section. The user section will live at http://example.com whilst the business section will live at http://business.example.com. Currently to route this I am checking for the domain in the routes file and using a different set of routes for each, something on the lines of:
$url = explode('http://', $_SERVER['HTTP_HOST']);
if($url[0] == 'business.example.com') {
// routes for the "business" section
$route['default_controller'] = 'business/homepage/index';
} else {
// all other routes
$route['default_controller'] = 'users/homepage/index';
}
I have also split my controllers up into two main folders, "business" and "users".
I am just wondering if this is actually the best way to achieve the desired routing in CodeIgniter or if anyone else can suggest a better approach.