A
A
Anton2016-08-30 12:55:20
Yii
Anton, 2016-08-30 12:55:20

How to remove controller/index from link?

Hello. I have a controller, for example, a site that has a default route of index, how to make it so that after following a link to this address, the default route is not displayed, that is, the link is domain/site and not domain/site/index.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Fedorov, 2016-08-30
Reytarovsky @Antonchik

If you need to make the main page of the site open as domain/site, then specify 'defaultRoute' => '/site' in the config.
If it's just a controller, then you can either simply refer to it without an action, for example:
or beat this situation through the urlManager rules, for example:

'rules' => [
    '<controller>' => '<controller>/index' // если ссылка вида controller/index - формируем ее просто как ссылку на контроллер
],

D
Dmitry, 2016-08-30
@slo_nik

Good afternoon.
In the configuration file, for urlManager, the rule is:
check the parameter in the same place
'showScriptName' => false,

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question