Flip URL with the router

I’ve never really used the router, but am i right in thinking i can completely re-craft the url for a page with it?

Specifically, I have a content folder at the top level of the site with subpages like this:

forms/subpage1
forms/subpage2
forms/subpage3

i want the URL to view these pages in the browser to be:

domain.com/subpage1/forms
domain.com/subpage2/forms
domain.com/subpage3/forms

This is a huge site and for maintenence reasons it makes sense store the content like this, but change the URL somehow.

Can i do this, and how please?

Something like this:

c::set('routes', array(
  array(
    'pattern' => '(:any)/forms',
    'action'  => function($uid) {

      $page = page($uid.'forms');

      if(!$page) $page = page('forms/' . $uid);
      if(!$page) $page = site()->errorPage();

      return site()->visit($page);

    }
  ),
  array(
    'pattern' => 'forms/(:any)',
    'action'  => function($uid) {
      go($uid.'/forms');
    }
  )
));

Awesome, that did the trick :slight_smile: Thank you.