Skip to content

Instantly share code, notes, and snippets.

@bval
Created February 19, 2013 21:33
Show Gist options
  • Save bval/4990191 to your computer and use it in GitHub Desktop.
Save bval/4990191 to your computer and use it in GitHub Desktop.
This is a router for Drupal and other PHP apps that rely on mod_rewrite rules for "clean URLs" so that those same apps can be run under PHP 5.4's built-in webserver which doesn't support mod_rewrite.
<?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