# Changing/customizing the URL of subpages

**URL:** <https://forum.getkirby.com/t/changing-customizing-the-url-of-subpages/3667>\
**Category:** Questions\
**Tags:** v2\
**Created:** [March 22, 2016, 5:21pm UTC](https://forum.getkirby.com/t/changing-customizing-the-url-of-subpages/3667 "2016-03-22T17:21:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![irvin](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/irvin/32/744_2.png) [@irvin](https://forum.getkirby.com/u/irvin)\
**Post date:** [March 22, 2016, 5:21pm UTC](https://forum.getkirby.com/t/changing-customizing-the-url-of-subpages/3667/1 "2016-03-22T17:21:47Z")

</div>

I have a website with categories, subcategories, and of course products. The folder structure looks like this:

```
Site
    > Shop
        > Category
            > Subcategory
                > Product
                > Product
                > Product

```

So the URL structures go something like:  
Categories: `website.com/shop/dresses/`  
Subcategories: `website.com/shop/dresses/homecoming`  
Product: `website.com/shop/dresses/homecoming/name-of-product`

I would like to change the url structures to look like this:  
For category and subcategory: `website.com/category/dresses/homecoming`  
Product: `website.com/dresses/homecoming/product-name`

Basically, replace ‘shop’ with ‘category’ for categories and subcategories. For the product, just remove ‘shop’ from URL.

How can I change the URL of subpages? Can you give me an example? I tried doing this myself using the documentation provided for routes but I’m a bit confused and I wasn’t able to get it to work the way I want.

Thanks!

---

<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 22, 2016, 5:32pm UTC](https://forum.getkirby.com/t/changing-customizing-the-url-of-subpages/3667/2 "2016-03-22T17:32:59Z")

</div>

I’m a bit confused, so you just want to get rid of shop, don’t you?

If so, you should be able to use the blog example but exchange `uid` with `diruri` to get the correct path to the page.

---

<div class="post-metadata">

**Author:** ![irvin](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/irvin/32/744_2.png) [@irvin](https://forum.getkirby.com/u/irvin)\
**Post date:** [March 22, 2016, 5:44pm UTC](https://forum.getkirby.com/t/changing-customizing-the-url-of-subpages/3667/3 "2016-03-22T17:44:02Z")

</div>

Yes, basically, but only for the product pages and for the categories/sub-category replace ‘shop’ with ‘category’.

Like this:  
(Replace ‘shop’ with ‘category’)  
Category old url: `website.com/shop/(category-name)/(subcategory-name)`  
Category new url: `website.com/category/(category-name)/(subcategory-name)`

(Remove ‘shop’ from url completely)  
Product old url: `website.com/shop/(category-name)/(product-name)`  
Product new url: `website.com/(category-name)/(product-name)`

---

<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:** [March 22, 2016, 6:12pm UTC](https://forum.getkirby.com/t/changing-customizing-the-url-of-subpages/3667/4 "2016-03-22T18:12:39Z")

</div>

To make this work, you need two routes:

1. A route that listens on `category/(:all)` and returns `return page('shop/' . $category)`
2. A route that simply “removes” the shop folder from the URL for the product pages. You can use the blog example from the routing docs for this.

Then you need to change the links to the products so that they use the correct URI scheme.

However please note that rerouting can lead to duplicate content if you don’t redirect the other URLs and it can also lead to unexpected results in other parts of your site since you potentially override top-level pages with the same name as a shop category.

---

<div class="post-metadata">

**Author:** ![irvin](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/irvin/32/744_2.png) [@irvin](https://forum.getkirby.com/u/irvin)\
**Post date:** [March 26, 2016, 8:27am UTC](https://forum.getkirby.com/t/changing-customizing-the-url-of-subpages/3667/5 "2016-03-26T08:27:35Z")

</div>

Thanks, I got it working. One more question, since I’m a little confused on what routers are suppose to do exactly, aren’t they suppose to also change the links on pages too?

The routing is working how it’s suppose to but the links on the website are still the same as they were before.

For example, on my websites menu, the links to the category pages should now be `website.com/category/category-name` but they still show up as `website.com/shop/category-name`

---

<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 26, 2016, 9:39am UTC](https://forum.getkirby.com/t/changing-customizing-the-url-of-subpages/3667/6 "2016-03-26T09:39:48Z")

</div>

The router does not create URLs, the original URL still exists, it is only redirected. Therefore, you will have to adapt your links in your menus if you want them to show the “new” URL.

Edit: See [this post](https://forum.getkirby.com/t/run-route-on-uri-to-get-original-page-object/1752/5) for using a page model to automate this:

---

<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, 4:59pm UTC](https://forum.getkirby.com/t/changing-customizing-the-url-of-subpages/3667/7 "2025-02-06T16:59:52Z")

</div>

Archived on February 6, 2025, 4:59pm UTC


