Multiple routes in Plugin causes 302 redirect, single route works

Hi, a bit struggeling with routes :slight_smile:

A single route like that, works fine in my Plugin:

        'method' => 'GET',
        'pattern' => 'student/liste/small',
        'action' => function () {
            return array("my_template", get_my_data() );
    } ) );

but multiple routes are allway redirect to homepage,…

$kirby->set('route', array(
      array (
        'method' => 'GET',
        'pattern' => 'student/liste/small',
        'action' => function () {  return array("my_small_template", get_small_data() );  } 
      ), array (
        'method' => 'GET',
        'pattern' => 'student/liste/large',
        'action' => function () {  return array("my_large_template", get_large_data() ); }
) );

Every route works fine in the above single route code-pattern, but all routes get redirect to home with a 302 Error with the second code snippet… i dont see whats missing there… any hint is welcome :slight_smile:

Use $kirby->set('routes', []) instead of route for multiple

Thanks for your reply. That leads to an error, because it seems not to be a valid key for Kirby.

Figured it out:


…does the trick. Now all routes work fine. Any explanation for this behaviour?

You right! Because of following line, parameter send already as array [$attr]:

1 Like