Commit 1a2eb53c17661f04320b4797c8453247a6d35fe6
1 parent
642cabb9
сделал редирект для главной страницы с www.siteName.com/////////////////////// на www.siteName.com
Showing
1 changed file
with
9 additions
and
4 deletions
Show diff stats
frontend/config/main.php
1 | <?php | 1 | <?php |
2 | use frontend\components\UrlManager; | 2 | use frontend\components\UrlManager; |
3 | - | 3 | +use yii\helpers\Url; |
4 | 4 | ||
5 | $params = array_merge( | 5 | $params = array_merge( |
6 | require( __DIR__ . '/../../common/config/params.php' ), | 6 | require( __DIR__ . '/../../common/config/params.php' ), |
@@ -11,15 +11,20 @@ | @@ -11,15 +11,20 @@ | ||
11 | 11 | ||
12 | return [ | 12 | return [ |
13 | 'on beforeRequest' => function () { | 13 | 'on beforeRequest' => function () { |
14 | - $pathInfo = Yii::$app->request->pathInfo; | 14 | + |
15 | + $pathInfo = Yii::$app->request->pathInfo; | ||
15 | $query = Yii::$app->request->queryString; | 16 | $query = Yii::$app->request->queryString; |
16 | - if (!empty($pathInfo) && substr($pathInfo, -1) === '/') { | 17 | + if (!empty($pathInfo) && substr($pathInfo, -1) === '/' && substr($pathInfo, 0, 1) !== "/") { |
17 | $url = '/' . substr($pathInfo, 0, -1); | 18 | $url = '/' . substr($pathInfo, 0, -1); |
18 | if ($query) { | 19 | if ($query) { |
19 | $url .= '?' . $query; | 20 | $url .= '?' . $query; |
20 | } | 21 | } |
21 | Yii::$app->response->redirect($url, 301); | 22 | Yii::$app->response->redirect($url, 301); |
22 | - } | 23 | + } # редирект с www.siteName.com//////////////////////// на www.siteName.com |
24 | + elseif (substr($pathInfo, 0, 1) == "/" && substr($pathInfo, 1, 1) == "/") { | ||
25 | + | ||
26 | + Yii::$app->response->redirect('/site/index', 301); | ||
27 | + } | ||
23 | }, | 28 | }, |
24 | 'id' => 'app-frontend', | 29 | 'id' => 'app-frontend', |
25 | 'homeUrl' => '/', | 30 | 'homeUrl' => '/', |