How to handle 404 in phalcon MVC

Hello~ I know that there is an event called dispatch:beforeException could handle 404 exceptions.

But I found that it couldn't handle requests like /111 or /中文. PhalconPHP will treat them as requesting '/`.

Is there any solutions? Thanks!

//Set 404 paths
    "controller" => "index",
    "action" => "route404"

Thank you! I have found this but I dont know how to integrate it to my existing code. I use Phalcon's native MVC router so I dont have a $router variable. I tried to copy Phalcon's native route rules and add notFound fallbacks but it seems not working well in all circumstances.

Could you give me a detailed example ? Thank you!

Show your code

This should work:

$DI->set('router',function() use($Config){
    $Router = new \Phalcon\Mvc\Router();
        "controller" => "index",
        "action" => "route404"
    return $Router;

The default route rules that Phalcon\Mvc\Router() have should still be in effect.