From bd3b5f18001367e2f46290a7240567768d27b2c3 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 16 Jun 2011 07:22:49 -0700 Subject: [PATCH] Improved URI detection. --- system/request.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/system/request.php b/system/request.php index be16faf1..bf439796 100644 --- a/system/request.php +++ b/system/request.php @@ -42,8 +42,6 @@ public static function uri() { throw new \Exception("Malformed request URI. Request terminated."); } - - $uri = str_replace('/index.php', '', $uri); } // ------------------------------------------------------- // Neither PATH_INFO or REQUEST_URI are available. @@ -53,6 +51,21 @@ public static function uri() throw new \Exception('Unable to determine the request URI.'); } + // ------------------------------------------------------- + // Remove the application URL. + // ------------------------------------------------------- + $base_url = parse_url(Config::get('application.url'), PHP_URL_PATH); + + if (strpos($uri, $base_url) === 0) + { + $uri = (string) substr($uri, strlen($base_url)); + } + + // ------------------------------------------------------- + // Remove the application index. + // ------------------------------------------------------- + $uri = str_replace('/index.php', '', $uri); + $uri = trim($uri, '/'); // -------------------------------------------------------