Apostrophe routing

Hi all -

By default Kirby replaces apostrophes with hyphens in a url, and I want to change this so there’s no replacement at all.

So for example, Ben’s Project becomes ‘ben-s-project’ but I want it to become ‘bend-project’.

I’ve tried doing this with the router in the config file but it’s just beyond my skills and was hoping someone could help!


Does this only concern a particular folder or a complete site?

The complete site really - there’s a couple of folders it relates to but i can’t see a reason not to roll it out to the whole thing really

Well, you would then have to check for every possible URL if any part of it contains an s at the end of a word and then reroute to the real page, plus change all the site’s URLs to reflect your desired URLs. Guess it would make more sense to either change the URLs manually at page creation or use a panel page update hook that actually changes the UID of the page after the page has been created.

Oh ok so there’s no way of creating a global rule?

I don’t know, maybe it’s really easy and all you have to do is check with some regex if the URL contains an s followed by a hyphen somewhere and then reroute to a page with a hyphen plus an s plus a hyphen…

Try this:

c::set('routes', array(
    'pattern' => '(.*)',
    'action'  => function($path) {

      $pattern = '/[s][-]/';

      $page = page($path);

      if(!$page) $page = page(preg_replace($pattern, '-s-', $path));
      if(!$page) $page = site()->errorPage();

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


But keep in mind that internal page links would still have the -s- in them, unless you use a custom page method to modify these internal links.

Edit, I just realized that this does not seem to work on the home page, so we’d probably need another check.