From e9fadaebd193bb2acfd16144170244a18e3f90a1 Mon Sep 17 00:00:00 2001 From: huangdijia Date: Wed, 23 Dec 2015 18:36:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96Response::redirect=E6=96=B9?= =?UTF-8?q?=E6=B3=95=EF=BC=8C=E6=94=AF=E6=8C=81=E4=BC=A0=E5=85=A5=E5=8E=9F?= =?UTF-8?q?=E7=94=9Furl=EF=BC=8C=E6=94=AF=E6=8C=81301/302=E4=BC=A0?= =?UTF-8?q?=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/response.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/library/think/response.php b/library/think/response.php index 22388cc9..db605bb8 100644 --- a/library/think/response.php +++ b/library/think/response.php @@ -204,13 +204,18 @@ class Response * URL重定向 * @access protected * @param string $url 跳转的URL表达式 - * @param array $params 其它URL参数 + * @param array|int $params 其它URL参数或http code * @return void */ public static function redirect($url, $params = []) { - $url = Url::build($url, $params); - header('Location: ' . $url); + $http_response_code = 302; + if(in_array($params, [301, 302])){ + $http_response_code = $params; + $params = []; + } + $url = preg_match('/^(https?:|\/)/', $s) ? $url : Url::build($url, $params); + header('Location: ' . $url, true, $http_response_code); } /**