Skip to content

Commit 8740b44

Browse files
committed
Config and routes update
1 parent 412c954 commit 8740b44

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

config/routes.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
# Docs - https://github.com/samdark/yii2-cookbook/blob/master/book/urls-variable-number-of-parameters.md
4+
return [
5+
// index rule for Canonical tag
6+
'' => 'site/index',
7+
// Other
8+
'p/<slug:\w+>' => 'site/page',
9+
// for Site controller
10+
// '<alias:\w+>' => 'site/<alias>',
11+
];

config/web.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
$config = [
77
'id' => 'simple',
8+
'name' => 'Сайт',
89
'basePath' => dirname(__DIR__),
910
'language' => 'ru-RU',
1011
'bootstrap' => ['log'],
@@ -70,12 +71,14 @@
7071
'urlManager' => [
7172
'enablePrettyUrl' => true,
7273
'showScriptName' => false,
73-
'rules' => [
74-
// need for right canonical
75-
'' => 'site/index',
76-
// for Site controller
77-
'<alias:\w+>' => 'site/<alias>',
74+
'suffix' => '/',
75+
'normalizer' => [
76+
'class' => 'yii\web\UrlNormalizer',
77+
'collapseSlashes' => true,
78+
'normalizeTrailingSlash' => true,
7879
],
80+
'rules' => require 'routes.php',
81+
7982
],
8083

8184
],

0 commit comments

Comments
 (0)