Router::scope('/:club_slug', function ($routes) {
$routes->connect('/login', ['controller' => 'Users', 'action' => 'login']);
});
So when I'm trying access http://example.com/club-name/login
, I'm being redirected to http://example.com/users/login
with the flash message You have to login to access this area
.
Auth loginAction
is [controller => 'Users', 'action' => 'login']
, since the custom route that I mentioned at beginning of the question is pointing to the path that is specified at loginAction
I thought the route will know that I'm talking about the same thing but is not what is happening.
Dynamic route elements are not being added/recognized automatically, you'll either have to persist them using either the
persist
option (applies only to that specific route):or URL filters (affects all routes that are using a
club_slug
element):or you have to pass the element to your login action manually (this would match the
club_slug
route regardless of the current URL):See also