Skip to content

Instantly share code, notes, and snippets.

@dereckson
Created November 23, 2014 11:14
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 dereckson/4aecefc5464891a6648b to your computer and use it in GitHub Desktop.
Save dereckson/4aecefc5464891a6648b to your computer and use it in GitHub Desktop.
<?php
/**
* Nasqueron Tools
*
* Router script to use built-in PHP server
*
* @package NasqueronTools
* @author Sébastien Santoro aka Dereckson <dereckson@espace-win.org>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @filesource
*
*/
$requestedFile = substr($_SERVER["REQUEST_URI"], 1);
if (array_key_exists('QUERY_STRING', $_SERVER)) {
$len = strlen($_SERVER['QUERY_STRING']) + 1;
$requestedFile = substr($requestedFile, 0, $len * -1);
}
if (file_exists($requestedFile) && !is_dir($requestedFile)) {
return false;
}
if (file_exists("$requestedFile.php")) {
$requestedFile .= '.php';
}
$_SERVER['PATH_INFO'] = '/' . $requestedFile;
require 'index.php';
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment