From 38a09943fe7148eee2df24b67a6f9e898b840f05 Mon Sep 17 00:00:00 2001 From: Chaim Date: Fri, 10 Jul 2020 01:58:25 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E4=BC=98=E5=8C=96=E8=B7=AF=E7=94=B1?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/service/RouteService.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/service/RouteService.php b/src/service/RouteService.php index 9b69686..dd38da8 100644 --- a/src/service/RouteService.php +++ b/src/service/RouteService.php @@ -34,10 +34,11 @@ class RouteService extends Service public function redirect(string $url = '', int $status = 302, bool $parameter = false) { if (empty($url)) $url = request()->scheme() . "://" . request()->host(); - if ($status === 302) header("Location: {$url}" . $parameter === true ? request()->query() : ''); - elseif ($status === 301) { - header('HTTP/1.1 301 Moved Permanently'); - header("Location: {$url}" . $parameter === true ? request()->query() : ''); - } + $param = http_build_query(request()->param()); + if ($status == 301) header('HTTP/1.1 301 Moved Permanently'); + if (empty($parameter)) header("Location: {$url}"); + elseif (empty($parameter) == false && empty($param) == true) header("Location: {$url}"); + else header("Location: {$url}?{$param}"); + exit; } }