php.net |  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: cmb@php.net Assigned: cmb (profile)
Status: Closed Package: Built-in web server
PHP Version: 5.6.13 OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: cmb@php.net
New email:
PHP Version: OS:

 

 [2015-09-05 17:18 UTC] cmb@php.net
Description:
------------
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:
--------------
foo
www


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-05 17:47 UTC] cmb@php.net
-Type: Bug +Type: Documentation Problem -Assigned To: +Assigned To: cmb
 [2015-09-05 17:47 UTC] cmb@php.net
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:

  /baz/
  /fool/baz/

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
feature.
 [2015-09-06 15:53 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=337759
Log: documented lookup of index.(php|html) in parent directories, and respective setting of PATH_INFO (fixes #70434)
 [2015-09-06 15:53 UTC] cmb@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 09:01:27 2024 UTC