OSDN Git Service

Make possible to use PHPRouter on a subpath folder as `localhost/app/web`
authorJefersson Nathan <admin@phpse.net>
Wed, 6 May 2015 13:42:36 +0000 (10:42 -0300)
committerJefersson Nathan <admin@phpse.net>
Mon, 15 Jun 2015 13:42:36 +0000 (10:42 -0300)
src/PHPRouter/Router.php

index 8986e9b..9b6092c 100755 (executable)
@@ -101,6 +101,9 @@ class Router
                 continue;
             }
 
+            $currentDir = dirname($_SERVER['SCRIPT_NAME']);
+            $requestUrl = trim(str_replace($currentDir, '', $requestUrl), '/');
+
             // check if request _url matches route regex. if not, return false.
             if (! preg_match("@^" . $this->basePath . $routes->getRegex() . "*$@i", $requestUrl, $matches)) {
                 continue;