Skip to content

Instantly share code, notes, and snippets.

@micahredding
Forked from bval/.htrouter.php
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save micahredding/2eb93d936ddd4e5fb4a5 to your computer and use it in GitHub Desktop.
Save micahredding/2eb93d936ddd4e5fb4a5 to your computer and use it in GitHub Desktop.
<?php
/**
* @file
* The router.php for clean-urls when use PHP 5.4.0 built in webserver.
*
* Usage:
*
* php -S localhost:3000 .htrouter.php
*
*/
$url = parse_url($_SERVER["REQUEST_URI"]);
if (file_exists('.' . $url['path'])) {
// Serve the requested resource as-is.
return FALSE;
}
// Remove opener slash.
$_GET['q'] = substr($url['path'], 1);
include 'index.php';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment