I don't understand how to set 404 page for any start number route and don't route to default index page.
If I goto https://localhost/404 (or any numbers), I see default index page, not 404 page.
This route:
$di->set('router', function () {
$router = new Router(false);
$router->setDefaultModule('frontend');
$router->add('/:action', [
'module' => 'frontend',
'controller' => 'index',
'action' => 1,
]);
$router->add('/:action/:params', [
'module' => 'frontend',
'controller' => 'index',
'action' => 1,
'params' => 2,
]);
$router->add('/:module/:controller/:action/:params', [
'module' => 1,
'controller' => 2,
'action' => 3,
'params' => 4,
]);
$router->removeExtraSlashes(true);
return $router;
});
And this dispatcher exception for default frantend module:
$dependencyInjector->setShared(
'dispatcher',
function () {
$eventManager = new Manager();
$eventManager->attach(
'dispatch:beforeException',
function ($event, $dispatcher, $exception) {
switch ($exception->getCode()) {
case Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
case Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
$dispatcher->forward([
'controller' => 'error',
'action' => 'notFound',
]);
return false;
}
}
);
$dispatcher = new Dispatcher();
$dispatcher->setDefaultNamespace('AudioOcean\Frontend\Controllers');
$dispatcher->setEventsManager($eventManager);
return $dispatcher;
}
);