|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60472 PHP_SELF/SCRIPT_NAME wrongly defined in $_SERVER
Submitted: 2011-12-08 16:11 UTC Modified: 2011-12-09 12:59 UTC
From: lolautruche at gmail dot com Assigned:
Status: Not a bug Package: Built-in web server
PHP Version: 5.4.0RC2 OS: Mac OS X 10.7.2 (Lion)
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: lolautruche at gmail dot com
New email:
PHP Version: OS:


 [2011-12-08 16:11 UTC] lolautruche at gmail dot com
By design, if no PHP script is present in the REQUEST_URI, built-in server 
considers using a directory index (index.php or index.html). However, PHP_SELF 
and SCRIPT_NAME server variables are not correctly filled.

For instance, if I test http://localhost:8000/hello/world, SCRIPT_NAME will be 
"/index.php" and PHP_SELF will be "/index.php/hello/world", while on Apache 
httpd, SCRIPT_NAME and PHP_SELF will be "/hello/world/index.php".

Test script:
php -S localhost:8000 router.php

router.php script :
var_dump( $_SERVER );

Expected result:
Directory index should be AFTER the dir path :

Actual result:
Directory index is before the dir path :


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-09 02:43 UTC]
is the hello/world is actually a existing folder under you doc root?  I think it's 

so actullay the built-in server will find the index.php under the doc_root, this 
is a feature(for path_info), not a bug.
 [2011-12-09 02:43 UTC]
-Status: Open +Status: Feedback
 [2011-12-09 10:26 UTC] lolautruche at gmail dot com

Indeed, it's a virtual folder. I was comparing built-in server behaviour with 
Apache HTTPD's.
So I guess you'd suggest to alter those server variables in the router script ?

 [2011-12-09 12:59 UTC]
-Status: Feedback +Status: Bogus
 [2011-12-09 12:59 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

this is not a bug, but a feature. thanks
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Feb 25 06:01:26 2024 UTC