Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
coordinate.systems custom kirby routing
<?php
/*
---------------------------------------
Custom Routes
---------------------------------------
*/
c::set('routes', array(
array(
'pattern' => 'feed.xml',
'action' => function() {
// Use the feed page for the URI /feed.xml
return page('feed');
}
),
array(
'pattern' => 'feed',
'action' => function() {
// Redirect /feed to /feed.xml
return go('feed.xml');
}
),
array(
'pattern' => 'sitemap.xml',
'action' => function() {
return site()->visit('sitemap');
}
),
array(
'pattern' => 'sitemap',
'action' => function() {
return go('sitemap.xml');
}
),
array(
'pattern' => 'in',
'action' => function() {
header::redirect('/', 301);
}
),
// array(
// 'pattern' => 'in/(:all)',
// 'action' => function($query) {
// header::redirect('/'.$query, 301);
// }
// ),
array(
'pattern' => '(:num)/(:all)',
'action' => function($year, $query) {
$inpage = '/in/' . $year . '/' .$query;
header::redirect($inpage, 301);
// return site()->visit($inpage);
}
),
array(
'pattern' => '(:num)',
'action' => function($year) {
$inpage = '/in/' . $year;
header::redirect($inpage, 301);
// return site()->visit($inpage);
}
),
));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.