|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66711 PHP_SELF has trailing slash for index.php
Submitted: 2014-02-13 22:32 UTC Modified: 2017-10-24 07:37 UTC
Avg. Score:3.7 ± 0.9
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: cmbecker69 at gmx dot de Assigned:
Status: Open Package: Built-in web server
PHP Version: 5.5.9 OS: Windows 7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: cmbecker69 at gmx dot de
New email:
PHP Version: OS:


 [2014-02-13 22:32 UTC] cmbecker69 at gmx dot de
When requesting the document root, the built-in webserver appends
a superfluous and AFAICT erroneous slash to $_SERVER['PHP_SELF'].

This does neither happen when the file index.php is requested
directly, nor when a subdirectory is requested.

Test script:


Expected result:
string(11) "/index.php/"

Actual result:
string(10) "/index.php"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-02-14 19:34 UTC] cmbecker69 at gmx dot de
I have to correct myself: it always happens when a trailing slash
is appended to the URL.

From what I can tell, this issue is related to the stat() call in
php_cli_server_request_translate_vpath().  While *nix (tested on
Cygwin) returns 0 for an existing directory with a trailing slash,
Windows returns -1 (on Windows the directory separator is properly
changed to backslash).  This bypasses the break on line 1509, and
causes prev_path to be changed to "\", what is later assigned to

In sapi_cli_server_register_variables() PHP_SELF is finally set by
using the wrong path_info[2].

My knowledge of C is limited, so I'm not able to appropriately fix
the bug; however, I've sent a respective phpt to the QA list[3].

[1] <>
[2] <>
[3] <>
 [2014-03-03 18:38 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: pajoye
 [2014-04-05 01:48 UTC] jakoch at web dot de
i think this is a duplicate of the slash-bug, reported at 
sadly the issue was closed without even checking it.
 [2014-04-05 11:07 UTC] cmbecker69 at gmx dot de
I have just noticed, that the expected and actual results given
above are permuted. That should have been:

Expected result:
string(10) "/index.php"

Actual result:
string(11) "/index.php/"
 [2014-04-05 11:34 UTC] cmbecker69 at gmx dot de
> i think this is a duplicate of the slash-bug, reported at

No, the issues are not related. I have filed a feature request
regarding the "trailing slash" redirect (#67027), because I assume
it is futile to add comments to an already closed bug report.
 [2017-10-24 07:37 UTC]
-Status: Assigned +Status: Open -Assigned To: pajoye +Assigned To:
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Jul 25 16:01:23 2021 UTC