public function getIndexForUri($uri)
{
preg_match('~\\/?(.*?\\.php)~', $uri, $matches);
if (!empty($matches[1])) {
$uri = '/' . $matches[1];
}
if (file_exists($this->root . $uri) && !is_dir($this->root . $uri)) {
return $this->root . $uri;
}
$uri = '/' . trim($uri, '/');
$indexFile = isset($this->map[$uri]) ? $this->map[$uri] : '/index.php';
return $this->root . $indexFile;
}