Hello,
Just found a weird case with routing on my site.
If I visit the base url:
All works fine.
If I try an undefined controller or anything with / that is not defined, it 404s properly:
https://site.com/fdsfds/dfdsfds
Defined routes work fine:
However, any request to something undefined with a special char doesn't 404 but shows the index page:
https://site.com/[email protected]
https://site.com/sdfds.dc/sdfdsf
These types all display the homepage. I want them to 404.
I'm using FactoryDefault.
My router:
$di->set('router', function(){
$router = new \Phalcon\Mvc\Router();
// camelize
$router->add('/([a-zA-Z\-]+)/([a-zA-Z\-]+)/:params', [
'controller' => 1,
'action' => 2,
'params' => 3
])->convert('action', function($action) {
return Phalcon\Text::lower(Phalcon\Text::camelize($action));
});
return $router;
}, true);
Dispatcher:
$di->set('dispatcher', function () {
// Create an EventsManager
$eventsManager = new Phalcon\Events\Manager();
$eventsManager->attach('dispatch:beforeException', function($event, $dispatcher, $exception) {
switch($exception->getCode()) {
case Phalcon\Mvc\Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
case Phalcon\Mvc\Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
$dispatcher->forward([
'controller' => 'error404',
'action' => 'index'
]);
return false;
}
});
$dispatcher = new Phalcon\Mvc\Dispatcher();
// Bind the EventsManager to the dispatcher
$dispatcher->setEventsManager($eventsManager);
return $dispatcher;
}, true);
Any ideas?