Commit eaa321f339f051b265902b8fb6b7961ec82f6ed6
1 parent
2ff97f34
301 redirect from www.siteName.com///////////////// to www.siteName.com
Showing
1 changed file
with
14 additions
and
1 deletions
Show diff stats
frontend/config/main.php
| @@ -9,6 +9,17 @@ | @@ -9,6 +9,17 @@ | ||
| 9 | ); | 9 | ); |
| 10 | 10 | ||
| 11 | return [ | 11 | return [ |
| 12 | + 'on beforeRequest' => function () { | ||
| 13 | + $pathInfo = Yii::$app->request->pathInfo; | ||
| 14 | + $query = Yii::$app->request->queryString; | ||
| 15 | + if (!empty($pathInfo) && substr($pathInfo, -1) === '/') { | ||
| 16 | + $url = '/' . substr($pathInfo, 0, -1); | ||
| 17 | + if ($query) { | ||
| 18 | + $url .= '?' . $query; | ||
| 19 | + } | ||
| 20 | + Yii::$app->response->redirect($url, 301); | ||
| 21 | + } | ||
| 22 | + }, | ||
| 12 | 'id' => 'app-frontend', | 23 | 'id' => 'app-frontend', |
| 13 | 'homeUrl' => '/', | 24 | 'homeUrl' => '/', |
| 14 | 'basePath' => dirname(__DIR__), | 25 | 'basePath' => dirname(__DIR__), |
| @@ -362,7 +373,9 @@ | @@ -362,7 +373,9 @@ | ||
| 362 | 'baseUrl' => '/', | 373 | 'baseUrl' => '/', |
| 363 | 'enablePrettyUrl' => true, | 374 | 'enablePrettyUrl' => true, |
| 364 | 'showScriptName' => false, | 375 | 'showScriptName' => false, |
| 365 | - 'rules' => [], | 376 | + 'rules' => [ |
| 377 | + | ||
| 378 | + ], | ||
| 366 | 'hideDefaultLanguagePrefix' => true, | 379 | 'hideDefaultLanguagePrefix' => true, |
| 367 | ], | 380 | ], |
| 368 | ], | 381 | ], |