PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTTP » HTTP » Bug #1858

Relative redirects don't work

Details

Submitted2004-07-12 22:01 UTC
Fromfred at eggheads dot ca
Assignedmike
StatusClosed
PackageHTTP
PHP Version4.3.7
OSFreeBSD 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