P
P
Petr Fronin2016-03-24 16:53:37
Yii
Petr Fronin, 2016-03-24 16:53:37

How to remove the name of 1 controller from the URL?

We have, for example, 2 controllers SiteController and UserController, respectively, the url is obtained :
mysite.ru/site/index
mysite.ru/user/index
accessing mysite.ru/index to access SiteController
The config now says:

'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' => '',
                ],

            ],
        ],

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
enchikiben, 2016-03-25
@amar_std

'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'enableStrictParsing' => true,
            'rules' => [
                '/' => 'site/index',
                '/index' => 'site/index',
                [
                    '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' => '',
                ],

            ],
        ],

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question