Route template to hash

how do i setup the kirby routing to to redirect the last part of the url on specific template.

for template ‘support-topic’ should be (with a # hash)

but other templates in same folder should not be redirected

ideally it would work on any depth in the folder tree.

c::set('routes', array(
    'pattern' => array('(:any)'),
    'action'  => function() {
      // compare if template is equal to 'support-topic' do that
      // else do nothing

Even simpler. In site/templates/support-topic.php:

<?php go($page->parent()->url() . '#' . $page->uid());

will this be a 301 or 302 redirect? or none at all?

The go() helper will use an HTTP 302 redirect.
If you need 301, use the following code:

<?php redirect::send($page->parent()->url() . '#' . $page->uid(), 301);
1 Like

hm. can the kirby router do 301? or do i need to use the htaccess file? i would still be intereseted in how to solve this with the router, too.