Home » HTTP » HTTP » Bug #1858
Relative redirects don't work
Details
| Submitted | 2004-07-12 22:01 UTC |
|---|---|
| From | fred at eggheads dot ca |
| Assigned | mike |
| Status | Closed |
| Package | HTTP |
| PHP Version | 4.3.7 |
| OS | FreeBSD 5.2.1 |
| Roadmaps | (Not assigned) |
Comments
[2004-07-12 22:01 UTC] fred at eggheads dot ca
Description:
------------
HTTP::redirect("x.php"); does not work. Trailing slash removed from path name before redirect.
From http://x.com/directory/ redirecting to x.php results in
http://x.com/directoryx.php instead of http://x.com/directory/x.php
Reproduce code:
---------------
HTTP::redirect("x.php");
Patch that fixes problem.
--- HTTP.php.orig Mon Jul 12 14:53:43 2004
+++ HTTP.php Mon Jul 12 14:53:06 2004
@@ -296,6 +296,10 @@
} else {
$path = dirname($_SERVER['PHP_SELF']);
}
+ // Ensure path ends in '/'
+ if ($path{strlen($path)} != '/') {
+ $path .= '/';
+ }
return $server . strtr($path, '\\', '/') . $url;
}
Expected result:
----------------
redirect to http://servername/test/x.php
Actual result:
--------------
redirect to http://servername/testx.php