Create a gist now

Instantly share code, notes, and snippets.

@tlongren /index.php
Last active Aug 29, 2015

What would you like to do?
AltoRouter index.php
<?php
header("Content-Type: text/html");
include dirname(__FILE__) . '/includes/AltoRouter.php';
$router = new AltoRouter();
$router->setBasePath('');
/* 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)
$router->map('GET','/charge/[*:customer_id]/','charge.php','charge');
$router->map('GET','/pay/[*:status]/','payment_results.php','payment-results');
// 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