From 5171ea302d546d35275a9e5b57a3becd9dae8b0f Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 13 Jun 2016 11:37:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=85=B3=E9=97=AD=E4=BC=AA?= =?UTF-8?q?=E9=9D=99=E6=80=81=E8=AE=BF=E9=97=AE=20=E8=AE=BE=E7=BD=AEurl=5F?= =?UTF-8?q?html=5Fsuffix=20=E4=B8=BAfalse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Request.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/library/think/Request.php b/library/think/Request.php index f079fcbd..f4c6a84c 100644 --- a/library/think/Request.php +++ b/library/think/Request.php @@ -349,8 +349,18 @@ class Request public function path() { if (is_null($this->path)) { - // 去除正常的URL后缀 - $this->path = preg_replace(Config::get('url_html_suffix') ? '/\.(' . trim(Config::get('url_html_suffix'), '.') . ')$/i' : '/\.' . $this->ext() . '$/i', '', $this->pathinfo()); + $suffix = Config::get('url_html_suffix'); + $pathinfo = $this->pathinfo(); + if(false === $suffix){ + // 禁止伪静态访问 + $this->path = $pathinfo; + }elseif($suffix){ + // 去除正常的URL后缀 + $this->path = preg_replace('/\.(' . ltrim($suffix, '.') . ')$/i' , '', $pathinfo); + }else{ + // 允许任何后缀访问 + $this->path = preg_replace('/\.' . $this->ext() . '$/i', '', $pathinfo); + } } return $this->path; }