From bf4dcdd19c9ed88cc1e1255374771e3c79dcab2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A1=E6=A0=8B?= Date: Tue, 21 Dec 2021 11:08:28 +0800 Subject: [PATCH] * adjust get api version. --- framework/api/router.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/framework/api/router.class.php b/framework/api/router.class.php index baf63f2ea1..e0cbc41d60 100644 --- a/framework/api/router.class.php +++ b/framework/api/router.class.php @@ -82,8 +82,10 @@ class api extends router $this->httpMethod = strtolower($_SERVER['REQUEST_METHOD']); - $fileName = ltrim(substr($_SERVER['SCRIPT_FILENAME'], strlen($_SERVER['DOCUMENT_ROOT'])), '/'); - $this->path = substr(ltrim($_SERVER['REQUEST_URI'], '/'), strlen($fileName) + 1); + $documentRoot = zget($_SERVER, 'CONTEXT_DOCUMENT_ROOT', $_SERVER['DOCUMENT_ROOT']); + $fileName = ltrim(substr($_SERVER['SCRIPT_FILENAME'], strlen($documentRoot)), '/'); + $webRoot = ltrim($this->config->webRoot, '/'); + $this->path = substr(ltrim($_SERVER['REQUEST_URI'], '/'), strlen($webRoot . $fileName) + 1); if(strpos($this->path, '?') > 0) $this->path = strstr($this->path, '?', true); $subPos = $this->path ? strpos($this->path, '/') : false;