# Flip URL with the router

**URL:** <https://forum.getkirby.com/t/flip-url-with-the-router/10000>\
**Category:** Questions\
**Tags:** v2\
**Created:** [March 16, 2018, 12:22pm UTC](https://forum.getkirby.com/t/flip-url-with-the-router/10000 "2018-03-16T12:22:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jimbobrjames](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jimbobrjames/32/5802_2.png) [@jimbobrjames](https://forum.getkirby.com/u/jimbobrjames)\
**Post date:** [March 16, 2018, 12:22pm UTC](https://forum.getkirby.com/t/flip-url-with-the-router/10000/1 "2018-03-16T12:22:15Z")

</div>

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:

```auto
forms/subpage1
forms/subpage2
forms/subpage3

```

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

```auto
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?

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [March 16, 2018, 12:46pm UTC](https://forum.getkirby.com/t/flip-url-with-the-router/10000/2 "2018-03-16T12:46:02Z")

</div>

Something like this:

```auto
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');
    }
  )
));

```

---

<div class="post-metadata">

**Author:** ![jimbobrjames](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jimbobrjames/32/5802_2.png) [@jimbobrjames](https://forum.getkirby.com/u/jimbobrjames)\
**Post date:** [March 16, 2018, 1:22pm UTC](https://forum.getkirby.com/t/flip-url-with-the-router/10000/3 "2018-03-16T13:22:15Z")

</div>

Awesome, that did the trick 🙂 Thank you.

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [February 6, 2025, 5:28pm UTC](https://forum.getkirby.com/t/flip-url-with-the-router/10000/4 "2025-02-06T17:28:38Z")

</div>

Archived on February 6, 2025, 5:28pm UTC


