V
V
VicTHOR2021-09-22 18:19:08
Yii
VicTHOR, 2021-09-22 18:19:08

How to remove duplicate URL in the rules of the UrlManager component without enableStrictParsing?

With this config

'components' => [
    'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                'login' => 'user/login'
            ],
        ],
]

The action user/loginis called both when domain.com/loginand when domain.com/user/login. How to remove the processing of the second URL without losing the functionality of the standard action call by matching the path and the controller (i.e. without enableStrictParsing = true, in which each route has to be registered)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav, 2021-09-23
@cr1gger

https://www.yiiframework.com/doc/api/2.0/yii-web-u...

Whether to enable strict parsing. If strict parsing is enabled, the incoming requested URL must match at least one of the rules in order to be considered a valid request. Otherwise, the path information portion of the request will be treated as the requested route. This property is only used when enablePrettyUrl is set to true

In general, you turn on strict mode (enableStrictParsing).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question