--- includes/common.inc_orig 2009-05-22 15:52:50.947464753 -0500 +++ includes/common.inc 2009-05-22 15:53:02.100489431 -0500 @@ -639,7 +639,17 @@ case 301: // Moved permanently case 302: // Moved temporarily case 307: // Moved temporarily - $location = $result->headers['Location']; + $location = parse_url($result->headers['Location']); + // If location isn't fully qualified URL (as per W3 RFC2616), build one + if (!isset($location['scheme']) && !isset($location['host'])) { + $check_scheme = isset($uri['scheme']) ? $uri['scheme'] : ''; + $check_host = isset($uri['host']) ? $uri['host'] : ''; + $check_port = isset($uri['port']) ? (':'. $uri['port']) : ''; + $location = $check_scheme .'://'. $check_host . $check_port .'/'. ltrim($result->headers['Location'], '/'); + } + else { + $location = $result->headers['Location']; + } if ($options['max_redirects']) { // Redirect to the new location. $options['max_redirects']--;