# Route to .xml or .xsl

**URL:** <https://forum.getkirby.com/t/route-to-xml-or-xsl/11681>\
**Category:** Questions\
**Tags:** v2\
**Created:** [November 19, 2018, 7:22pm UTC](https://forum.getkirby.com/t/route-to-xml-or-xsl/11681 "2018-11-19T19:22:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lukehatfield](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukehatfield/32/386_2.png) [@lukehatfield](https://forum.getkirby.com/u/lukehatfield)\
**Post date:** [November 19, 2018, 7:22pm UTC](https://forum.getkirby.com/t/route-to-xml-or-xsl/11681/1 "2018-11-19T19:22:52Z")

</div>

I’m catching everything in a route but want to let a few things through like sitemap.xml and sitemap.xsl. If I say `return go($uid)` it’s an infinite loop, and if I say `return site->visit($uid)` it goes to error page not found because there is no template related to those files.

I need kirby to ignore these two `$uid`s in the route, and continue loading as normal so the route from the sitemap plugin can catch these. Unfortunately, my pattern is `array('/(:all)', '(any)')` and catches everything. What is the command to continue routing as usual if I don’t want to do anything with these urls? I’m need a method that says, `kirby continue normal routing process`.

---

<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:** [November 19, 2018, 7:36pm UTC](https://forum.getkirby.com/t/route-to-xml-or-xsl/11681/2 "2018-11-19T19:36:09Z")

</div>

I think a route filter can do that.

[https://getkirby.com/docs/developer-guide/toolkit/routing#creating-routing-filters](https://getkirby.com/docs/developer-guide/toolkit/routing#creating-routing-filters)

---

<div class="post-metadata">

**Author:** ![lukehatfield](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukehatfield/32/386_2.png) [@lukehatfield](https://forum.getkirby.com/u/lukehatfield)\
**Post date:** [November 20, 2018, 4:03pm UTC](https://forum.getkirby.com/t/route-to-xml-or-xsl/11681/3 "2018-11-20T16:03:45Z")

</div>

@texnixe thank you. Some general routing questions: how is registering a new router different than running `$kirby->set('route', array(...`?

From the documentation, it seems like there are three steps here:

1. Register the new router
2. Apply the filter
3. Run the router

And if I’m making a new router and running it, what happens to the old kirby router? Which one gets applied first?

---

<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:** [November 20, 2018, 4:32pm UTC](https://forum.getkirby.com/t/route-to-xml-or-xsl/11681/4 "2018-11-20T16:32:35Z")

</div>

You don’t have to create your own router, it should actually work in a standard config setting, see these two answers from the same thread for possible solutions:

> [@How to filter a global route to exclude some specific paths](https://forum.getkirby.com/t/how-to-filter-a-global-route-to-exclude-some-specific-paths/10293/2):
>
> This seems to work: kirby()-\>routes([['pattern' =\> '(:any)', 'action' =\> function($uid) { $page = page($uid); if(!$page) $page = page('database/' . $uid); if(!$page) $page = site()-\>errorPage(); return site()-\>visit($page); }, 'filter' =\> function($route) { if(in\_array('sitemap.xml', $route-\>arguments())) { return false; } },] ]);

> [@How to filter a global route to exclude some specific paths](https://forum.getkirby.com/t/how-to-filter-a-global-route-to-exclude-some-specific-paths/10293/3):
>
> Filters are not really meant to restrict the pattern of the route, their main use-case is authentication and other “environment checks”. The best way would be defining the pattern in a way that excludes the sitemap in the first place: kirby()-\>routes(array( array( 'pattern' =\> '^(?!sitemap\.xml$)(.\*)$', 'action' =\> function($uid) { $page = page($uid); if(!$page) $page = page('database/' . $uid); if(!$page) $page = site()-\>errorPage(); return…

---

<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:25pm UTC](https://forum.getkirby.com/t/route-to-xml-or-xsl/11681/5 "2025-02-06T17:25:52Z")

</div>


