# Removing filters (i.e. "page:") from URL via Routing

**URL:** <https://forum.getkirby.com/t/removing-filters-i-e-page-from-url-via-routing/5281>\
**Category:** Questions\
**Tags:** v2\
**Created:** [September 18, 2016, 8:28pm UTC](https://forum.getkirby.com/t/removing-filters-i-e-page-from-url-via-routing/5281 "2016-09-18T20:28:26Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ShawnCollier](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/shawncollier/32/2927_2.png) [@ShawnCollier](https://forum.getkirby.com/u/ShawnCollier)\
**Post date:** [September 18, 2016, 8:28pm UTC](https://forum.getkirby.com/t/removing-filters-i-e-page-from-url-via-routing/5281/1 "2016-09-18T20:28:26Z")

</div>

I was attempting to follow the last example in the documentation as seen below. My code is also below.

[https://getkirby.com/docs/developer-guide/advanced/routing](https://getkirby.com/docs/developer-guide/advanced/routing)

```
c::set('routes', array(
    array(
        'pattern' => 'reviews/page:(:num)',
        
        'action' => function($page) {
            go('reviews/'.$page);
        }
    ),
    
    array(
        'pattern' => 'reviews/(:num)',
        
        'action' => function($page) {
            return site()->visit(page('reviews/page:'.$page));
        }
    )
));

```

Essentially I have pagination setup, so there’s URLs such as **[website.com/reviews/page:2](http://website.com/reviews/page:2)** that I want to change to **[website.com/reviews/2](http://website.com/reviews/2)**. But when I try going to the URL right now, it directs me back to the homepage. If I put a **error\_log()** command in the second **array()** statement, I do see **$page** is being passed through properly.

I searched on the forums, but the other posts appear to delve into issues that don’t involve numerical rewriting or the pagination like my issue does, so I’m a bit stumped. I have a feeling it’s a simple fix, but I’m not sure what the issue is.

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [September 18, 2016, 8:33pm UTC](https://forum.getkirby.com/t/removing-filters-i-e-page-from-url-via-routing/5281/2 "2016-09-18T20:33:47Z")

</div>

`page:2` is a so-called param, it’s not part of the page URI. You can’t currently set those params manually, but you can switch your pagination from the `params` method to the `query` method and use the following code in your second route:

```auto
$_GET['page'] = $page;
return site()->visit(page('reviews'));

```

---

<div class="post-metadata">

**Author:** ![ShawnCollier](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/shawncollier/32/2927_2.png) [@ShawnCollier](https://forum.getkirby.com/u/ShawnCollier)\
**Post date:** [September 18, 2016, 9:13pm UTC](https://forum.getkirby.com/t/removing-filters-i-e-page-from-url-via-routing/5281/3 "2016-09-18T21:13:22Z")

</div>

So I’m using this now:

```
c::set('routes', array(
    array(
        'pattern' => 'reviews/?page=(:num)',
        
        'action' => function($page) {
            go('reviews/'.$page);
        }
    ),
    
    array(
        'pattern' => 'reviews/(:num)',
        
        'action' => function($page) {
            $_GET['page'] = $page;
            return site()->visit(page('reviews'));
        }
    )
));

```

But in regards to the pagination method switching you talked about, how do I do that? In my controller, I declare the pagination as such:

`$pagination = $reviews->pagination();`

Is there a flag I add here? I can’t seem to find anything in the documentation.

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [September 19, 2016, 9:11am UTC](https://forum.getkirby.com/t/removing-filters-i-e-page-from-url-via-routing/5281/4 "2016-09-19T09:11:06Z")

</div>

The following will probably not work because query params are not part of the pattern:

```auto
'pattern' => 'reviews/?page=(:num)'

```

You need to do this redirection from the `reviews` template.

> [@ShawnCollier](#):
>
> But in regards to the pagination method switching you talked about, how do I do that? In my controller, I declare the pagination as such:

You can set the method in the `paginate()` method:

```auto
$reviews->paginate($limit, ['method' => 'query']);

```

---

<div class="post-metadata">

**Author:** ![ShawnCollier](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/shawncollier/32/2927_2.png) [@ShawnCollier](https://forum.getkirby.com/u/ShawnCollier)\
**Post date:** [September 28, 2016, 2:28am UTC](https://forum.getkirby.com/t/removing-filters-i-e-page-from-url-via-routing/5281/5 "2016-09-28T02:28:00Z")

</div>

Ah, I see. I’ll note that for future reference then.

I ended up using a slightly alternate method (something similar to [How to cleanup/remove the (tag:) from url](https://forum.getkirby.com/t/how-to-cleanup-remove-the-tag-from-url/708/10)), but I’ll keep this in mind in case I need it.

Apologizes for getting back to this post so late, been really busy with work and other IRL stuff and haven’t had much time to check things.

---

<div class="post-metadata">

**Author:** ![Jonathan](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jonathan/32/182_2.png) [@Jonathan](https://forum.getkirby.com/u/Jonathan)\
**Post date:** [June 25, 2017, 7:07pm UTC](https://forum.getkirby.com/t/removing-filters-i-e-page-from-url-via-routing/5281/6 "2017-06-25T19:07:14Z")

</div>

Hi Shawn, I run into this thread, because I am trying to achieve exactly the same thing regarding to pagination.

You mention you used a slightly altered method compared to the one mentioned in the thread about cleaning up the tag from the url. I have tried many things, but I cannot figure it out.

Please, could you elaborate on your solution. I would really like to hear (see some code) about how you managed this… that would be awesome.

---

<div class="post-metadata">

**Author:** ![ShawnCollier](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/shawncollier/32/2927_2.png) [@ShawnCollier](https://forum.getkirby.com/u/ShawnCollier)\
**Post date:** [June 25, 2017, 7:23pm UTC](https://forum.getkirby.com/t/removing-filters-i-e-page-from-url-via-routing/5281/7 "2017-06-25T19:23:21Z")

</div>

I had to revert to the “stock” URL method unfortunately, and the code I had before got nuked due to my Git repo getting corrupted a while back and needing to be recreated.

So I don’t have the code I would have used back then anymore, sadly.

---

<div class="post-metadata">

**Author:** ![Jonathan](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jonathan/32/182_2.png) [@Jonathan](https://forum.getkirby.com/u/Jonathan)\
**Post date:** [June 26, 2017, 10:57am UTC](https://forum.getkirby.com/t/removing-filters-i-e-page-from-url-via-routing/5281/8 "2017-06-26T10:57:13Z")

</div>

That’s a bummer 😉 But thanks for your fast reply.

I’ll try out some more… and if I can figure something out I’ll let you know here.

---

<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:35pm UTC](https://forum.getkirby.com/t/removing-filters-i-e-page-from-url-via-routing/5281/9 "2025-02-06T17:35:28Z")

</div>

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


