From 2918ae9c7ab86208be25d5652d94c14685c59faa Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 9 Jul 2013 21:01:38 -0400 Subject: [PATCH] Update index.php to serve static files with query strings. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Trim off the query string before attempting to locate the file on the filesystem. Thanks to Marko Marković for the initial patch. Fixes #3910 --- app/webroot/index.php | 3 ++- lib/Cake/Console/Templates/skel/webroot/index.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/webroot/index.php b/app/webroot/index.php index 3a5862bf9..988343293 100644 --- a/app/webroot/index.php +++ b/app/webroot/index.php @@ -79,7 +79,8 @@ if (!defined('WWW_ROOT')) { // for built-in server if (php_sapi_name() == 'cli-server') { - if ($_SERVER['REQUEST_URI'] !== '/' && file_exists(WWW_ROOT . $_SERVER['REQUEST_URI'])) { + $uri = str_replace($_SERVER['SCRIPT_FILENAME'], WWW_ROOT, ''); + if ($_SERVER['REQUEST_URI'] !== '/' && file_exists(WWW_ROOT . $uri)) { return false; } $_SERVER['PHP_SELF'] = '/' . basename(__FILE__); diff --git a/lib/Cake/Console/Templates/skel/webroot/index.php b/lib/Cake/Console/Templates/skel/webroot/index.php index 0b4c4d696..58aad8a3b 100644 --- a/lib/Cake/Console/Templates/skel/webroot/index.php +++ b/lib/Cake/Console/Templates/skel/webroot/index.php @@ -79,7 +79,8 @@ if (!defined('WWW_ROOT')) { // for built-in server if (php_sapi_name() === 'cli-server') { - if ($_SERVER['REQUEST_URI'] !== '/' && file_exists(WWW_ROOT . $_SERVER['REQUEST_URI'])) { + $uri = str_replace($_SERVER['SCRIPT_FILENAME'], WWW_ROOT, ''); + if ($_SERVER['REQUEST_URI'] !== '/' && file_exists(WWW_ROOT . $uri)) { return false; } $_SERVER['PHP_SELF'] = '/' . basename(__FILE__);