$registry = Registry::getInstance(); $registry->set('application', new Application(dirname(__FILE__))); $registry->set('site', new Site); foreach ( Registry::getInstance()->get('application')->routes as $route ) { if ( FALSE !== $route->parse($_SERVER['REQUEST_URI']) ) break; } if ( FALSE === $route->data ) die('Route not found.'); if ( $_SERVER['REQUEST_URI'] != ( $actualUri = $route->build($route->data) ) ) { header('Location: '.$actualUri); exit; } $registry->set('route', $route);