I’m migrating a Kirby 1 site and have a page that used to work like this:
share/id:40895825/
I’m converting it to use get()
and the format:
share?id=40895825
The problem is that I want to make sure old “share” links continue to work. I figured I could do this with the router but am not able to get it working. Is it possible to catch share/id:whatever
and redirect to share?id=whatever
?
Thanks for any help!
Yes, this should be possible with the Router.
I haven’t tried the following code but something like this should do it:
c::set('routes', array(
array(
'pattern' => 'share/id:(:any)',
'action' => function($id) {
$page = page('share?id='.$id);
go($page);
}
)
));
Hope that helps!
Edit: Just realised that it’s been a few months since this question was posted. Dunno if it’s still relevant.
Thanks so much @Targoran! It’s been a while but I will definitely try this. I put the Kirby migration on hold due to this issue and got busy doing other things. I appreciate you posting!
Great to hear that it’s not too late.
Let me know how things turn out!