How to make friends urlManager with the rules in the config:

 'urlManager' => [ 'class' => 'yii\web\UrlManager', 'enablePrettyUrl' => true, 'showScriptName' => false, 'enableStrictParsing' => true, 'rules' => [ '/' => 'site/index', '/admin' => 'admin/default/index', '<action>'=>'site/<action>', '<controller:\w+>/<id:\d+>' => '<controller>/view', '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>', '<controller:\w+>/<action:\w+>' => '<controller>/<action>', '<module:\w+>/<controller:\w+>/<action:\w+>/<id:\d+>' => '<module>/<controller>/<action>', '<module:\w+>/<controller:\w+>/<action:\w+>' => '<module>/<controller>/<action>', '<module:\w+>/<controller:\w+>' => '<module>/<controller>/index', ], ], 

with the rules described in the module (in this case, the module Yii2-user is given)

 /** @var array The rules to be used in URL management. */ public $urlRules = [ '<id:\d+>' => 'profile/show', '<action:(login|logout)>' => 'security/<action>', '<action:(register|resend)>' => 'registration/<action>', 'confirm/<id:\d+>/<code:\w+>' => 'registration/confirm', 'forgot' => 'recovery/request', 'recover/<id:\d+>/<code:\w+>' => 'recovery/reset', 'settings/<action:\w+>' => 'settings/<action>' ]; 

    1 answer 1

    Look here: http://www.yiiframework.com/doc-2.0/guide-runtime-routing.html#adding-rules

    transfer:

    URL rules can be added to the URL manager dynamically. This is often necessary for distributed modules that want to manage their own URl rules. In order for dynamically added rules to take effect in the routing process, you must add them at the bootstrapping stage. For modules, this means that they must implement the yii \ base \ BootstrapInterface and add rules to the bootstrap () method as in the example:

     public function bootstrap($app) { $app->getUrlManager()->addRules([ // rule declarations here ], false); } 

    Note that you must also specify these modules in
    yii \ web \ Application :: bootstrap () so that they participate in the self-tuning process