Commit 09140c4348a0f492932be430661465b33691e490
1 parent
dd34be36
direct redirects
Showing
2 changed files
with
47 additions
and
0 deletions
Show diff stats
frontend/config/main.php
1 | <?php | 1 | <?php |
2 | use artbox\core\components\LanguageRequest; | 2 | use artbox\core\components\LanguageRequest; |
3 | use artbox\core\components\SeoUrlManager; | 3 | use artbox\core\components\SeoUrlManager; |
4 | + use frontend\models\DirectRedirects; | ||
4 | 5 | ||
5 | $params = array_merge( | 6 | $params = array_merge( |
6 | require( __DIR__ . '/../../common/config/params.php' ), | 7 | require( __DIR__ . '/../../common/config/params.php' ), |
@@ -51,6 +52,9 @@ | @@ -51,6 +52,9 @@ | ||
51 | 'urlManager' => [ | 52 | 'urlManager' => [ |
52 | 'class' => SeoUrlManager::className(), | 53 | 'class' => SeoUrlManager::className(), |
53 | 'enablePrettyUrl' => true, | 54 | 'enablePrettyUrl' => true, |
55 | + 'redirects' => [ | ||
56 | + DirectRedirects::className(), | ||
57 | + ], | ||
54 | 'showScriptName' => false, | 58 | 'showScriptName' => false, |
55 | 'processRoutes' => [ | 59 | 'processRoutes' => [ |
56 | 'page/view', | 60 | 'page/view', |
1 | +<?php | ||
2 | + | ||
3 | + namespace frontend\models; | ||
4 | + | ||
5 | + use artbox\core\models\interfaces\RedirectInterface; | ||
6 | + use yii\base\Object; | ||
7 | + | ||
8 | + /** | ||
9 | + * Created by PhpStorm. | ||
10 | + * User: timur | ||
11 | + * Date: 06.11.17 | ||
12 | + * Time: 17:43 | ||
13 | + */ | ||
14 | + | ||
15 | + class DirectRedirects extends Object implements RedirectInterface{ | ||
16 | + | ||
17 | + protected $link; | ||
18 | + | ||
19 | + public function doRedirect(string $url): bool | ||
20 | + { | ||
21 | + $redirectArray = [ | ||
22 | + '/site/about' => '/ru/o-klinike', | ||
23 | + '/site/gallery' => '/ru/gallery', | ||
24 | + '/blog/index' => '/ru/blog', | ||
25 | + '/site/price' => '/ru/price', | ||
26 | + '/site/contact' => '/ru/contacts', | ||
27 | + '/persone/index' => '/ru/persons', | ||
28 | + '/site/comments' => '/ru/comments', | ||
29 | + ]; | ||
30 | + | ||
31 | + if (array_key_exists($url, $redirectArray)){ | ||
32 | + $this->link = $redirectArray[$url]; | ||
33 | + return true; | ||
34 | + } | ||
35 | + | ||
36 | + return false; | ||
37 | + } | ||
38 | + | ||
39 | + public function getLink(): string | ||
40 | + { | ||
41 | + return trim($this->link, "/"); | ||
42 | + } | ||
43 | + } | ||
0 | \ No newline at end of file | 44 | \ No newline at end of file |