Created
February 19, 2013 21:33
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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