Skip to content

Instantly share code, notes, and snippets.

@maxfenton
Created April 16, 2016 15:45
Show Gist options
  • Save maxfenton/88c5301b5a350a5a128ab84bd16ac72c to your computer and use it in GitHub Desktop.
Save maxfenton/88c5301b5a350a5a128ab84bd16ac72c to your computer and use it in GitHub Desktop.
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