|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #70434 cli-server doesn't handle missing directories properly
Submitted: 2015-09-05 17:18 UTC Modified: 2015-09-06 15:53 UTC
From: Assigned: cmb (profile)
Status: Closed Package: Built-in web server
PHP Version: 5.6.13 OS: *
Private report: No CVE-ID: None
 [2015-09-05 17:18 UTC]
When a directory is requested, the built-in web server looks for
index.(html|php) in this directory; if such a file does not exist,
it responds with 404. Fine.

However, if the directory does not exists, the web server looks
in the parent folder for index.(html|php) and serves that instead.
If index.(html|php) doesn't exist, the lookup continues recursively
until the docroot is reached.

Test script:
mkdir www
echo www > www/index.html
mkdir www/foo
echo foo > www/foo/index.html
mkdir www/foo/bar
echo bar > www/foo/bar/index.html
php -S localhost:8080

curl http://localhost:8080/foo/baz 2>/dev/null | head -n 1
curl http://localhost:8080/fool/baz 2>/dev/null | head -n 1

Expected result:
<!doctype html><html><head><title>404 Not Found</title><style>
<!doctype html><html><head><title>404 Not Found</title><style>

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-05 17:47 UTC]
-Type: Bug +Type: Documentation Problem -Assigned To: +Assigned To: cmb
 [2015-09-05 17:47 UTC]
Ah, everything get's clearer, if the index.html files are replaced
with index.php files:

  <?php echo $_SERVER['PATH_INFO'];
Then the output is:


That is not really correct, but is obviously rather handy to have
considering that the built-in server doesn't support rewrite
rules. So this is not a bug, but rather a yet undocumented
 [2015-09-06 15:53 UTC]
Automatic comment from SVN on behalf of cmb
Log: documented lookup of index.(php|html) in parent directories, and respective setting of PATH_INFO (fixes #70434)
 [2015-09-06 15:53 UTC]
-Status: Assigned +Status: Closed
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Jul 31 07:01:23 2021 UTC