php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74205 PATH_INFO only partial support
Submitted: 2017-03-04 17:09 UTC Modified: 2017-10-26 12:43 UTC
Votes:2
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: remi@php.net Assigned:
Status: Open Package: Built-in web server
PHP Version: Next Minor Version OS: irrevelant
Private report: No CVE-ID: None
 [2017-03-04 17:09 UTC] remi@php.net
Description:
------------
According to documentation http://php.net/manual/en/features.commandline.webserver.php

"URI requests are served from the current working directory where PHP was started, unless the -t option is used to specify an explicit document root. 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. If an index.php or index.html is found, it is returned and $_SERVER['PATH_INFO'] is set to the trailing part of the URI. Otherwise a 404 response code is returned."

So we can understand this as the apache rewirte equiv to

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

But as soon as the URI contain a dot, this doesn't work.

Also see http://discourse.slimframework.com/t/path-issue-404-on-some-routes-using-php-builtin-webserver/1193


Test script:
---------------
With a tree containif only a index.php

wget  -q http://localhost:8888/foo/bar
wget  -q http://localhost:8888/foo-1.1/bar
wget  -q http://localhost:8888/foo/bar.png


Expected result:
----------------
PHP 7.2.0-dev Development Server started at Sat Mar  4 18:07:49 2017
Listening on http://localhost:8888
Document root is /work/build/phpmaster
Press Ctrl-C to quit.
[Sat Mar  4 17:56:34 2017] 127.0.0.1:39094 [200]: /foo/bar
[Sat Mar  4 17:56:42 2017] 127.0.0.1:39096 [200]: /foo-1.1/bar
[Sat Mar  4 17:56:46 2017] 127.0.0.1:39104 [200]: /foo/bar.png


Actual result:
--------------
PHP 7.2.0-dev Development Server started at Sat Mar  4 18:07:49 2017
Listening on http://localhost:8888
Document root is /work/build/phpmaster
Press Ctrl-C to quit.
[Sat Mar  4 18:07:53 2017] 127.0.0.1:39402 [200]: /foo/bar
[Sat Mar  4 18:07:57 2017] 127.0.0.1:39404 [404]: /foo-1.1/bar - No such file or directory
[Sat Mar  4 18:08:01 2017] 127.0.0.1:39412 [404]: /foo/bar.png - No such file or directory


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-03-04 17:10 UTC] remi@php.net
-Summary: PATH_INFO partially support +Summary: PATH_INFO only partial support
 [2017-03-04 17:14 UTC] requinix@php.net
Would the PR also fix bug #74061?
 [2017-03-04 17:20 UTC] remi@php.net
Yes, also fix 74061
 [2017-10-26 12:25 UTC] cmb@php.net
> If neither file exists, the lookup for index.php and index.html
> will be continued in the parent directory […]

It seems to me that this lookup must not occur (respectively,
stop), if the specified (or any intermediate) resource exists.
Say, there is the following structure:

  /foo/ 
  /index.php

Requesting /foo should respond with 404 (or show the directory
listing); requesting /bar should be interpreted as /index.php/bar,
i.e. serving /index.php with /bar as PATH_INFO.
 [2017-10-26 12:43 UTC] cmb@php.net
> It seems to me that this lookup must not occur (respectively,
> stop), if the specified (or any intermediate) resource exists.

To clarify: on the other hand, the lookup must always happen if
the resource does not exist, regardless wether there is a dot or
not.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 02 11:01:28 2024 UTC