Issue
Routes.php
$routes->scope('/', function (RouteBuilder $builder) {
$builder->connect('/', ['controller' => 'Users', 'action' => 'login']);
$builder->connect('/pages/*', 'Pages::display');
$builder->fallbacks();
});
File structure
How to add Admin login page as root page of the website?
Something like this
$routes->scope('/Admin/UserController', function (RouteBuilder $builder) {
$builder->connect('/Admin/UserController', ['controller' => 'Users', 'action' => 'login']);
});
Solution
That's not how you're supposed to connect routes, you don't put stuff like UserController
in your path, the path defines the URL format!
If you want to connect /
to your admin prefixed controller, then you need to pass the prefix
option in the route defaults accordingly, for example:
$routes->scope('/', function (RouteBuilder $builder) {
// connect the URL `/` to `\App\Controller\Admin\UsersController::login()`
$builder->connect('/', [
'prefix' => 'Admin',
'controller' => 'Users',
'action' => 'login',
]);
// shorthand variant of the above
// $builder->connect('/', 'Admin/Users::login');
$builder->connect('/pages/*', 'Pages::display');
$builder->fallbacks();
});
See also
Answered By - ndm
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.