Redirect from parent page to child

for organizational reasons, there is a parent page with the actual subpages. So that they are better sorted.

  • Products
    – Product Variant A
    – Product Variant B

These two pages are Type-A and Type-B and the Type-A page should be called instead of the parent page.

How do I get that in Kirby 2? A change to version 3 is unfortunately too time-consuming.

You can use a route that returns the first subpage when the parent is called. An a second one that redirects to the parent when the first child is called.

You might want to use a page model that overrides the url() method for the first child.

When your variants use a specific template (e.g. productvariant), you could use a template like this:

// site/templates/productvariant.php
<?php go($page->parent()->url(), 301); ?>

it was time for a quick solution. so i take the Redirect-Plugin for kirby2 from @flokosiol.
So you can easy switch in the panel for a redirect. very cool for this way. thanks.

1 Like