我知道这是一个老问题,但这对我有用。这可能会为某人指明正确的方向。也请随时向我询问有关代码的详细信息。
//$route['default_controller'] = "welcome";
$route['404_override'] = ''; 开关($_SERVER['HTTP_HOST'])
{
case 'losey.co':
case 'www.losey.co':
$route['default_controller'] = "dashboard";
break;
default:
//This query's the sites table and checks the domain / subdomain and then shows the correct default_controller
$server = $_SERVER['HTTP_HOST'];
require_once( BASEPATH .'database/DB'. EXT );
$db =& DB();
$db->where('nameshort', array_shift(explode(".",$server)));
$db->or_where('domain', $server);
$query = $db->get( 'sites' );
//$query = $db->get_where('sites', array('nameshort' => 'test'), 1);
$result = $query->result();
foreach( $result as $row )
{
$route['default_controller'] = $row->home;
}
break;