Form submission not working after I employ Kirby's URL reroute in config.php

I am using the approach described by Kirby here to re-route my blog’s home page URL from to just (without the “/blog”) needed in the URL:
Routing | Omitting the blog folder in URLs

However, I also am using a form on the blog post pages to collect and display comments, via this plugin:

As soon as I implemented the re-route, whenever I try to submit a comment (testing this live, not on localhost anymore) I get the 404 page. The comments are written to sub-pages of the blog post, and their content is stored there and pulled back into the blog post to be displayed. There seems to be an issue with the submit button’s action now that the URL is rerouted, it can’t find where it is supposed to send/create the individual comment sub-page maybe?

I have read this page about routing, regarding Actions but I can’t get it to help me.

Is there a way to fix this with Kirby’s re-routing functionalities? Many, many thanks in advance for any help.

By default, Kirby’s router is set to GET methods. Add the POST method to your routes like this:

c::set('routes', array(
    'pattern' => '(:any)',
    'method' => 'GET|POST',
    'action'  => function($uid) {

      $page = page($uid);

      if(!$page) $page = page('blog/' . $uid);
      if(!$page) $page = site()->errorPage();

      return site()->visit($page);

    'pattern' => 'blog/(:any)',
    'method' => 'GET|POST',
    'action'  => function($uid) {

1 Like

That worked! Thank you so much! :grinning: