Hi alle, i have this urlManager configuration:
'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' => false, 'normalizer' => [ 'class' => 'yii\web\UrlNormalizer', 'collapseSlashes' => true, 'normalizeTrailingSlash' => true, 'action' => null, ], 'rules' => [ [ 'pattern' => 'ug/<namespace:[a-z0-9]+(?:-[a-z0-9]+)*>/user', 'route' => '/user/login', ], [ 'pattern' => '/ug/<namespace:[a-z0-9]+(?:-[a-z0-9]+)*>/', 'route' => 'user-gallery', ] ], ],
with the request: "example.com/xxx" it works fine and redirect "example.com/user-gallery"
with the request: “example.com/xxx/user” it doesn’t work with the exception “404 not found” and the message:
yii\base\InvalidRouteException Object ( [message:protected] => Unable to resolve the request "xxx/user/login"
with the request: "example.com/user/login" i have the right login page.
I think my problem is that the urlManager remove the "/" from the start of the route, beacuse the request "/xxx/user/login" works fine.
I try change the route in "user/login", "/user/login", "//user/login" but i see in the source code of yii2/framework/web/UrlRule.php
$this->route = trim($this->route, '/');
I see also that i don’t have a controller UserController.php because it is a module.
If i change the route into "site/index" works fine.
So i don’t know how can i do.