Skip to content

Instantly share code, notes, and snippets.

@tlongren
Created October 25, 2013 01:53
Show Gist options
  • Save tlongren/7148314 to your computer and use it in GitHub Desktop.
Save tlongren/7148314 to your computer and use it in GitHub Desktop.
AltoRouter index.php
<?php
header("Content-Type: text/html");
require 'AltoRouter.php';
$router = new AltoRouter();
$router->setBasePath('');
/* Setup the URL routing. This is production ready. */
$router->map('GET','/', 'home.php', 'home');
$router->map('GET','/home/', 'home.php', 'home-specific');
$router->map('GET','/home', 'home.php', 'home-specific-noslash');
$router->map('GET','/signup/', 'home.php', 'signup');
$router->map('GET','/signup', 'home.php', 'signup-noslash');
$router->map('GET','/hosts/', 'hosts.php', 'hosts');
$router->map('GET','/hosts', 'hosts.php', 'hosts-noslash');
$router->map('GET','/contact/', 'contact.php', 'contact');
$router->map('GET','/contact', 'contact.php', 'contact-noslash');
$router->map('GET','/dashboard/', 'dashboard-new.php', 'dashboard');
$router->map('GET','/dashboard', 'dashboard-new.php', 'dashboard-noslash');
$router->map('GET','/signout/', 'signout.php', 'signout');
$router->map('GET','/signout', 'signout.php', 'signout-noslash');
/* Maintenance URL routing */
/*$router->map('GET','/', 'maintenance.php', 'home');
$router->map('GET','/home/', 'maintenance.php', 'home-specific');
$router->map('GET','/home', 'maintenance.php', 'home-specific-noslash');
$router->map('GET','/signup/', 'maintenance.php', 'signup');
$router->map('GET','/signup', 'maintenance.php', 'signup-noslash');
$router->map('GET','/hosts/', 'maintenance.php', 'hosts');
$router->map('GET','/hosts', 'maintenance.php', 'hosts-noslash');
$router->map('GET','/contact/', 'maintenance.php', 'contact');
$router->map('GET','/contact', 'maintenance.php', 'contact-noslash');
$router->map('GET','/dashboard/', 'maintenance.php', 'dashboard');
$router->map('GET','/dashboard', 'maintenance.php', 'dashboard-noslash');
$router->map('GET','/signout/', 'maintenance.php', 'signout');
$router->map('GET','/signout', 'Maintenance.php', 'signout-noslash');*/
/* 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