Kohana 3.3 catch-all route

kohana, php, routes

Solution

This should work:

Route::set('foobar', '<catcher>',array('catcher'=>'.*')) 
    -> defaults(array(
        'directory' => 'site',
        'controller' => 'foobar',
        'action' => 'foobar',
));

It `<catcher>` is a placeholder and `array('catcher'=>'.*')` defines the catcher to match the regex `.*`

Problem

How can I define a route that will catch all requests and forward them to one specific controller? I've already tried adding the default route ``` Route::set('default', '(<controller>(/<action>(/<id>)))') ->defaults(array( 'directory' => 'site', 'controller' => 'foobar', 'action' => 'foobar', )); ``` or ``` Route::set('default', '(.*)') -> defaults(array( 'directory' => 'site', 'controller' => 'foobar', 'action' => 'foobar', )); ``` to my bootstrap.php, but it doesn't work. After typing localhost/a I get either ``` Unable to find a route to match the URI: a ``` or ``` The requested URL a was not found on this server. ``` error. I'm sure that the controller is valid, as ``` Route::set('foobar', 'foo') -> defaults(array( 'directory' => 'site', 'controller' => 'foobar', 'action' => 'foobar', )); ``` works fine. I'm using Kohana 3.3.

Original source