// By default goto pages (this is redundant because at the end of this we redirect everything anyway) $route['default_controller'] = "simple_page"; $route['scaffolding_trigger'] = ""; // These are NOT controllers so ignore them $excluded_controllers = array( '.', '..', 'index.html' ); // Loop through all files in the controllers directory (I am not sure if this is recursive) $handle = opendir(APPPATH . 'controllers/'); while (($file = readdir($handle)) !== FALSE) { if (!in_array($file,$excluded_controllers)) { $installed_controllers[] = substr($file, 0, strrpos($file, '.')); } } closedir($handle); // Create the routing rules for all of the controllers that we found foreach ($installed_controllers as $controller) { $route[$controller] = $controller; $route[$controller . '/(.*)'] = $controller . '/$1'; } $route['(.*)'] = 'simple_page/index/$1';