Catalin
Catalin

Reputation: 803

Yii2 module url modification

In my app I have a module located in:

/frontend/modules/reports/controllers/TheModule.php/

frontend/modules/reports/controllers/views/the-module/index.php

The url for this is

frontend/web/reports/the-module/index

How can I have the url like this:

frontend/web/the-module/index ?

Because if I navigate to the module url as it is now, all the links in the main menu (which is common throughout the site) will get a /reports in their url.

Note that I am using the default url manager.

Upvotes: 0

Views: 235

Answers (1)

Bizley
Bizley

Reputation: 18021

Try this in frontend configuration:

return [
    // ...
    'components' => [
        // ...
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                'the-module/<action>' => 'reports/the-module/<action>'
            ],
        ],
    ],
];

Upvotes: 0

Related Questions