Answer the question
In order to leave comments, you need to log in
How to properly configure urlManager in Yii2?
Dear comrades!!! Please help me deal with the issue...
Common/config/main.php says:
'components' => [
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'enableStrictParsing' => true,
'rules' => [
[
'pattern' => '',
'route' => '',
'suffix' => '',
],
[
'pattern' => '<controller>/<action>/<id:\d+>',
'route' => '<controller>/<action>',
'suffix' => '',
],
[
'pattern' => '<controller>/<action>',
'route' => '<controller>/<action>',
'suffix' => '',
],
[
'pattern' => '<module>/<controller>/<action>/<id:\d+>',
'route' => '<controller>/<action>',
'suffix' => '',
],
[
'pattern' => '<module>/<controller>/<action>',
'route' => '<controller>/<action>',
'suffix' => '',
],
],
],
]
'components' => [
'urlManager' => [
'baseUrl' => '',
],
]
'components' => [
'urlManager' => [
'baseUrl' => '/admin/',
],
]
<IfModule mod_rewrite.c>
Options -Indexes
RewriteEngine On
</IfModule>
<IfModule mod_rewrite.c>
RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
RewriteRule ^admin/?(.*) backend/web/index.php/$1 [L]
RewriteRule ^(.*)$ frontend/web/index.php/$1 [L]
</IfModule>
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
[
'pattern' => '<action>/<id>',
'route' => 'site/<action>',
'suffix' => '',
],
[
'pattern' => '<action>',
'route' => 'site/<action>',
'suffix' => '',
],
Answer the question
In order to leave comments, you need to log in
Solved the problem in this way:
[
'pattern' => '<action>/<id>',
'route' => 'site/<action>',
'suffix' => '',
],
[
'pattern' => '<action>',
'route' => 'site/<action>',
'suffix' => '',
],
'pattern' => 'index',
'route' => 'site/index',
'suffix' => '',
rules=>[
'index' => 'site/index',
]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question