Skip to content

Instantly share code, notes, and snippets.

@tlongren
Last active August 29, 2015 13:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tlongren/9038883 to your computer and use it in GitHub Desktop.
Save tlongren/9038883 to your computer and use it in GitHub Desktop.
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