Answer the question
In order to leave comments, you need to log in
How to address all pages to one route in Yii2 in UrlManager?
There is a design that redirects any page in the root to site/index, but how to do this for any nesting?
PS it is advisable to leave enablePrettyUrl enabled.
PPS: what does the \w+ parameter do?
'urlManager' => [
'class' => 'yii\web\UrlManager',
'showScriptName' => false,
'enablePrettyUrl' => true,
'rules' => [
'<alias:\w+>' => 'site/index',
],
],
Answer the question
In order to leave comments, you need to log in
'<url:(.*)>' => 'site/index',
\w+ is a regular expression string. w - Matches any alphanumeric character from the basic Latin alphabet, including the underscore character. Equivalent to the character set [A-Za-z0-9_]. The + symbol means one or more characters from the set [A-Za-z0-9_]
It is useful to read about named parameters
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question