|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35933 URL rewriting fails on ob_get_contents()
Submitted: 2006-01-08 17:46 UTC Modified: 2006-01-08 18:42 UTC
From: ernest at vogelsinger dot at Assigned:
Status: Not a bug Package: Output Control
PHP Version: 5.1.1 OS: any
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: ernest at vogelsinger dot at
New email:
PHP Version: OS:


 [2006-01-08 17:46 UTC] ernest at vogelsinger dot at
URL Rewriting fails on ob_get_contents().
Note: the workaround is to have second buffering envelope which gets flushed into the first, thus triggering the URL rewrite. The two lines necessary for the workaround are commented out in the code example.

Reproduce code:
$output = <<<EOF
<a href=".">self link</a>

// *** ob_start();
echo $output;
// *** ob_end_flush();
$data = ob_get_contents();
echo '<xmp>';
if (defined('SID'))
	echo 'URL should be rewritten having: ', SID, "\n";
	echo "No SID, no rewritten URL\n";
echo "<xmp>$data</xmp>";

Expected result:
URL should be rewritten having: PHPSESSID=667e6b2bde474a2820c8e0f8dc41200f
<a href=".?PHPSESSID=667e6b2bde474a2820c8e0f8dc41200f">self link</a> </body></html>

Actual result:
URL should be rewritten having: PHPSESSID=667e6b2bde474a2820c8e0f8dc41200f
<a href=".">self link</a> </body></html>


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-08 17:51 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

 [2006-01-08 18:42 UTC] ernest at vogelsinger dot at
Thanks for your omments that this is not a bug - IMHO it is actually a bug, not a feature.
URL rewriting should happen at the final stage, when the output is actually flushed back to the client, not at any other obscure location within the PHP output buffers.
I'll post a comment on the respective manual page (which I have read and fully understood ;->)
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun Jun 11 02:03:37 2023 UTC