浏览代码

Fix Pico's REQUEST_URI routing method when installed to /

Daniel Rudolf 8 年之前
父节点
当前提交
53e9eaa5e4
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      lib/Pico.php

+ 2 - 1
lib/Pico.php

@@ -965,7 +965,8 @@ class Pico
 
 
         // use REQUEST_URI (requires URL rewriting); e.g. /pico/sub/page
         // use REQUEST_URI (requires URL rewriting); e.g. /pico/sub/page
         if (($this->requestUrl === null) && $this->isUrlRewritingEnabled()) {
         if (($this->requestUrl === null) && $this->isUrlRewritingEnabled()) {
-            $basePath = dirname($_SERVER['SCRIPT_NAME']) . '/';
+            $basePath = dirname($_SERVER['SCRIPT_NAME']);
+            $basePath = !in_array($basePath, array('.', '/')) ? $basePath . '/' : '/';
             $basePathLength = strlen($basePath);
             $basePathLength = strlen($basePath);
 
 
             $requestUri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
             $requestUri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';