diff --git a/.ht.router.php b/.ht.router.php index 2a61a7d..1d93a21 100644 --- a/.ht.router.php +++ b/.ht.router.php @@ -3,17 +3,14 @@ * @file * Routing-script for the built-in PHP web server. * - * This script provides basic support for clean URLs by faking the "q" query - * parameter as the main .htaccess would do. - * - * The built-in webserver should _only_ be used for development and test as it + * The built-in webserver should only be used for development and testing as it * has a number of limitations that makes running Drupal on it highly insecure * and somewhat limited. * * In particular be aware that: * - The server is single-threaded, any requests made during the execution of * the main request will hang until the main request has been completed. - * - The webserver does not enforce any of the settings in .htacccess in + * - The webserver does not enforce any of the settings in .htaccess in * particular a remote user will be able to download files that normally * would be protected from direct access such as .module files. * @@ -23,14 +20,26 @@ * @see http://php.net/manual/en/features.commandline.webserver.php */ -$url = parse_url($_SERVER["REQUEST_URI"]); +$url = parse_url($_SERVER['REQUEST_URI']); if (file_exists('.' . $url['path'])) { // Serve the requested resource as-is. return FALSE; } -// Populate the "q" query key with the path, skip the leading slash. -$_GET['q'] = $_REQUEST['q'] = substr($url['path'], 1); +// The use of a router-script means that a number of $_SERVER variables has to +// be updated to point to the index-file. +$index_file_absolute = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'index.php'; +$index_file_relative = DIRECTORY_SEPARATOR . 'index.php'; + +// SCRIPT_FILENAME will point to the router-script itself, it should point to +// the full path to index.php. +$_SERVER['SCRIPT_FILENAME'] = $index_file_absolute; + +// SCRIPT_NAME and PHP_SELF will either point to /index.php or contain the full +// virtual path being requested depending on the url being requested. They +// should always point to index.php relative to document root. +$_SERVER['SCRIPT_NAME'] = $index_file_relative; +$_SERVER['PHP_SELF'] = $index_file_relative; -// Include the main index.php and let core take over. -include 'index.php'; +// Include the main index-file and let core take over. +include $index_file_absolute;