add($fc,'frontcontroller'); // routes $routes = array("/" => "/index/index"); Registry::getInstance()->add($routes,'routes'); // cleanroute //$currentroute = $_SERVER['REQUEST_URI']; preg_match("/^([^\?]*)(\?.*)?$/",$currentroute,$currentrouteparts); $currentroute = $currentrouteparts[1]; // strip trailing / $currentroute = preg_replace("/^\/(.*)\/$/","/\\1",$currentroute); // check if route is in routetable foreach (Registry::getInstance()->get('routes') as $routefrom => $routeto) { $regex = '/^'.str_replace("/","\/",$routefrom).'$/'; if (preg_match($regex,$currentroute)) { // create new route $currentroute = preg_replace($regex,$routeto,$currentroute); break; } } // do the action $fc->dispatch($currentroute); exit;