From 1f612a96bc987ba20ad4dc56ae57b45a389c8fc7 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 14 Jan 2016 16:57:23 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=AF=E7=94=B1=E6=A3=80=E6=B5=8B=E7=9A=84do?= =?UTF-8?q?main=E6=9D=A1=E4=BB=B6=E6=94=AF=E6=8C=81=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E5=AD=90=E5=9F=9F=E5=90=8D=20=E6=B7=BB=E5=8A=A0restful=20?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E6=96=B9=E6=B3=95=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Route.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/library/think/Route.php b/library/think/Route.php index ce757ca7..e32b8456 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -385,7 +385,7 @@ class Route // 请求类型检测 if ((isset($option['method']) && false === stripos($option['method'], REQUEST_METHOD)) || (isset($option['ext']) && false === stripos($option['ext'], __EXT__)) // 伪静态后缀检测 - || (isset($option['domain']) && $_SERVER['HTTP_HOST'] != $option['domain']) // 域名检测 + || (isset($option['domain']) && 0 === stripos($option['domain'] . '.', $_SERVER['HTTP_HOST'])) // 域名检测 || (!empty($option['https']) && !self::isSsl()) // https检测 || (!empty($option['behavior']) && false === Hook::exec($option['behavior'])) // 行为检测 || (!empty($option['callback']) && is_callable($option['callback']) && false === call_user_func($option['callback'])) // 自定义检测 @@ -502,8 +502,13 @@ class Route $controller = !empty($path) ? array_pop($path) : null; $module = APP_MULTI_MODULE && !empty($path) ? array_pop($path) : null; } - $action = '[rest]' == $action ? REQUEST_METHOD : $action; - $route = [$module, $controller, $action]; + // REST 操作方法支持 + if ('[rest]' == $action) { + $action = REQUEST_METHOD; + } elseif (Config::get('url_rest_action')) { + $action = REQUEST_METHOD . '_' . $action; + } + $route = [$module, $controller, $action]; } return ['route' => $route, 'var' => $var]; }