Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 13:56
What would you like to do?
AltoRouter index.php
header("Content-Type: text/html");
include dirname(__FILE__) . '/includes/AltoRouter.php';
$router = new AltoRouter();
/* Setup the URL routing. This is production ready. */
// Main routes that non-customers see
$router->map('GET','/', 'home.php', 'home');
$router->map('GET','/home/', 'home.php', 'home-home');
$router->map('GET','/plans/', 'plans.php', 'plans');
$router->map('GET','/about/', 'about.php', 'about');
$router->map('GET','/contact/', 'contact.php', 'contact');
$router->map('GET','/tos/', 'tos.html', 'tos');
// Special (payments, ajax processing, etc)
// API Routes
$router->map('GET','/api/[*:key]/[*:name]/', 'json.php', 'api');
/* Match the current request */
$match = $router->match();
if($match) {
require $match['target'];
else {
header("HTTP/1.0 404 Not Found");
require '404.html';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment