Omitting parts of URLs

I tried it on mine and the following works. However I believe there is a bug because it should have worked by just replacing :any with :all and using just one varialbe, instead of doing (:any)(:all)

c::set('routes', array(
   array(
      'pattern' => 'clients/(:all)',
      'action'  => function($uid) {
         go($uid);
      }
   ),
   array(
      'pattern' => '(:any)(:all)',
      'action'  => function($u1,$u2) {
         $page = page($u1.$u2);

         if(!$page) $page = page('clients/' . $u1.$u2);
         if(!$page) $page = site()->errorPage();

         return site()->visit($page);
      }
   )
));
4 Likes