From eaa321f339f051b265902b8fb6b7961ec82f6ed6 Mon Sep 17 00:00:00 2001 From: dozer111 Date: Fri, 8 Jun 2018 12:42:26 +0200 Subject: [PATCH] 301 redirect from www.siteName.com///////////////// to www.siteName.com --- frontend/config/main.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/frontend/config/main.php b/frontend/config/main.php index 9f89147..34e7a03 100755 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -9,6 +9,17 @@ ); return [ + 'on beforeRequest' => function () { + $pathInfo = Yii::$app->request->pathInfo; + $query = Yii::$app->request->queryString; + if (!empty($pathInfo) && substr($pathInfo, -1) === '/') { + $url = '/' . substr($pathInfo, 0, -1); + if ($query) { + $url .= '?' . $query; + } + Yii::$app->response->redirect($url, 301); + } + }, 'id' => 'app-frontend', 'homeUrl' => '/', 'basePath' => dirname(__DIR__), @@ -362,7 +373,9 @@ 'baseUrl' => '/', 'enablePrettyUrl' => true, 'showScriptName' => false, - 'rules' => [], + 'rules' => [ + + ], 'hideDefaultLanguagePrefix' => true, ], ], -- libgit2 0.21.4