# URL change of child pages

**URL:** <https://forum.getkirby.com/t/url-change-of-child-pages/29181>\
**Category:** Questions\
**Tags:** v3\
**Created:** [July 27, 2023, 3:06pm UTC](https://forum.getkirby.com/t/url-change-of-child-pages/29181 "2023-07-27T15:06:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kia](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/kia/32/11393_2.png) [@Kia](https://forum.getkirby.com/u/Kia)\
**Post date:** [July 27, 2023, 3:06pm UTC](https://forum.getkirby.com/t/url-change-of-child-pages/29181/1 "2023-07-27T15:06:18Z")

</div>

I’ve [build the site](https://kiakamgar.com), uploaded to the server and everything is gravy.

I know that child pages take their parent page as their directory…

So… `blog/page-name`

I’ve managed to find a way to change this by using the config file…

```auto
'routes' => [
  [
  'pattern' => 'post/(:any)',
  'action' => function ($uid) { return page('blog/'.$uid); }
  ],

```

This gives me `post/page-name` and works great!

I could have done this via `.htaccess` file, but wanted the URL to look right in the browser bar.

Anyway, in my analytics (I use Fathom) I still see the old directory of `/blog` rather than the new one called `/post`.

If this something that could be resolved, or would I have to live with it messing with my analytics?

Cheers in advance!

---

<div class="post-metadata">

**Author:** ![pixelijn](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@pixelijn](https://forum.getkirby.com/u/pixelijn)\
**Post date:** [July 27, 2023, 3:22pm UTC](https://forum.getkirby.com/t/url-change-of-child-pages/29181/2 "2023-07-27T15:22:46Z")

</div>

> [@Kia](#):
>
> If this something that could be resolved, or would I have to live with it messing with my analytics?

Well, you do a simple redirect, however, you should actually use two routes for this use case:

1. that does the redirect
2. the one that returns the correct page

See: [https://getkirby.com/docs/guide/routing#removing-the-parent-page-slug-from-the-url](https://getkirby.com/docs/guide/routing#removing-the-parent-page-slug-from-the-url)

In addition to that, you should modifiy what the url method returns. So create a page model for the subpage page type with the modified URL.

> **[Page models](https://getkirby.com/docs/guide/templates/page-models)**
>
> Page models extend Kirby's default $page object. Methods that you define in a page model are available everywhere in Kirby where you call a page of the extended type.
