|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25804 _SERVER['REQUEST_URI'] does not capture fragment
Submitted: 2003-10-09 09:31 UTC Modified: 2003-10-09 10:09 UTC
From: greg at freephile dot com Assigned:
Status: Not a bug Package: HTTP related
PHP Version: 4.3.3 OS: RH Linux 8.0
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
46 - 36 = ?
Subscribe to this entry?

 [2003-10-09 09:31 UTC] greg at freephile dot com
When a URI includes a fragment, that fragment is not captured as part of the $_SERVER['REQUEST_URI'] variable, so it is not possible to use parse_url() to get the fragment.  As an example,  the following request will NOT have the fragment in the $_SERVER['REQUEST_URI'] variable:

Instead, the $_SERVER['REQUEST_URI'] is given as '/admin/test.php?foo=bar'

I use PHP to process outgoing site links on, but due to this problem, I cannot redirect to external URIs containing a fragment.  The workaround is to recode those URIs into two querystring variables and then reconstruct the URI: to=

$externalSiteURI = $_REQUEST['to'] . $_REQUEST['fragment'];

Reproduce code:

(this link may be fixed with a workaround by the time you get this message)

Expected result:
$_SERVER['REQUEST_URI'] = '/admin/test.php?foo=bar#fragment'

Actual result:
$_SERVER['REQUEST_URI'] = '/admin/test.php?foo=bar'


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-09 10:09 UTC]
Browsers never send this part of URI to the server so there is no way it can be "captured".
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 15 07:01:29 2024 UTC