Bug->Doc #75061 [Opn]: Built-in web server does not look up existing parent dirs for index files

From: Date: Fri, 11 Aug 2017 02:37:06 +0000
Subject: Bug->Doc #75061 [Opn]: Built-in web server does not look up existing parent dirs for index files
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-14887@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75061&edit=1 ID: 75061 Updated by: requinix@php.net Reported by: me at alex dot bio -Summary: Built-in web server does not look up parent dirs for index files +Summary: Built-in web server does not look up existing parent dirs for index files Status: Open -Type: Bug +Type: Documentation Problem Package: Built-in web server Operating System: Mac OS X 10.12.6 PHP Version: 7.1.8 Block user comment: N Private report: N New Comment: The traversal only happens for portions of the path that do not exist, and continues up until the parent does exist. At that point there needs to be an index file (if the parent is a directory) or else PHP responds with a 404. Given the file /a/index.html and directories /a/b/c, - /a/b/c will 404 (/a/b/c exists without index) - /a/b/x will 404 (/a/b/x not found, /a/b exists without index) - /a/x/y works (/a/x/y not found, /a/x not found, /a exists with index) /a/index.html/x/y works for the same reasons. I think this is a documentation issue: I assume the intent is to match other web servers' behavior and I believe they work the same way (or at least Apache does). Previous Comments: ------------------------------------------------------------------------ [2017-08-10 19:45:18] me at alex dot bio Description: ------------ --- From manual page: http://www.php.net/features.commandline.webserver --- Documentation states that: If a URI request does not specify a file, then either index.php or index.html in the given directory are returned. *****If neither file exists, the lookup for index.php and index.html will be continued in the parent directory***** and so on until one is found or the document root has been reached. In reality index files from parent directories are not loaded and 404 Not Found error is returned. Looks like the bug is here: https://github.com/php/php-src/blame/master/sapi/cli/php_cli_server.c#L1400 Code returns instead of trying the parent index.[php|html]. Test script: --------------- Local directory structure: D www/ F www/index.php D www/subdir/ Built-in web server is launched like this: php -S localhost:8888 -t www Opening http://localhost:8888/dir/ in the browser fails with 404 error and the root index.php is not loaded. Expected result: ---------------- Documentation states that built-in server should open index.[php|html] in the parent root folder "If a URI request does not specify a file". The expected result is that the root folder's index.php should be loaded instead of 404 error. Actual result: -------------- opening http://localhost:8888/dir/ fails with 404 error and the root index.php is not loaded. opening http://localhost:8888/dir also fails with 404 error and the root index.php is not loaded. opening http://localhost:8888/notexistingdir works and correctly loads www/index.php. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75061&edit=1

« previous php.doc.bugs (#14887) next »