# Routes and $page-\>url() doesn't match

**URL:** <https://forum.getkirby.com/t/routes-and-page-url-doesnt-match/1768>\
**Category:** Questions\
**Tags:** v2\
**Created:** [August 4, 2015, 9:39pm UTC](https://forum.getkirby.com/t/routes-and-page-url-doesnt-match/1768 "2015-08-04T21:39:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevin](https://avatars.discourse-cdn.com/v4/letter/k/2acd7d/32.png) [@kevin](https://forum.getkirby.com/u/kevin)\
**Post date:** [August 4, 2015, 9:39pm UTC](https://forum.getkirby.com/t/routes-and-page-url-doesnt-match/1768/1 "2015-08-04T21:39:28Z")

</div>

I used the following route from the Doc:

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

      $page = page($uid);

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

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

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

```

In my Menu the old “/blog/my-article” is linked (generated automatic) by `$page->url()`. The redirect works correct (if I click on my link linked to “/blog/my-article” will be redirected to “/my-article”). But in the html sourcecode “/blog/my-article” is linked. Is there a way to automatic set the `$page->url()` to the new route (“/my-article”) defined in the config.php?

---

<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:** [August 5, 2015, 6:17pm UTC](https://forum.getkirby.com/t/routes-and-page-url-doesnt-match/1768/2 "2015-08-05T18:17:26Z")

</div>

This is a similar post:

> [@Run route on uri to get original $page object](https://forum.getkirby.com/t/run-route-on-uri-to-get-original-page-object/1752/6):
>
> This won’t work out of the box, as Kirby doesn’t know about your custom routes and the custom logic you use for them. To change the links to your routed pages, you can use a page model and set the url method on it to override the URL with a custom one.

---

<div class="post-metadata">

**Author:** ![kevin](https://avatars.discourse-cdn.com/v4/letter/k/2acd7d/32.png) [@kevin](https://forum.getkirby.com/u/kevin)\
**Post date:** [August 5, 2015, 7:46pm UTC](https://forum.getkirby.com/t/routes-and-page-url-doesnt-match/1768/3 "2015-08-05T19:46:34Z")

</div>

That works great, thanks!

---

<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:16pm UTC](https://forum.getkirby.com/t/routes-and-page-url-doesnt-match/1768/4 "2025-02-06T17:16:56Z")

</div>


