If the header returns an absolute path as a redirect, don't simply append the path to the old URL, remove the old absolute path first.
For example, original URL: http://www.theregister.co.uk/2013/07/28/birmingham_uni_car_cracker_muzzled_by_lords/print.html Redirect from header: /Print/2013/07/28/birmingham_uni_car_cracker_muzzled_by_lords/ Incorrect result: http://www.theregister.co.uk/2013/07/28/birmingham_uni_car_cracker_muzzled_by_lords/print.html/Print/2013/07/28/birmingham_uni_car_cracker_muzzled_by_lords/ Correct result after this patch: http://www.theregister.co.uk/Print/2013/07/28/birmingham_uni_car_cracker_muzzled_by_lords/
This commit is contained in:
parent
04681618da
commit
eb9bd03ef8
|
@ -93,7 +93,7 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_
|
||||||
$newurl = trim(array_pop($matches));
|
$newurl = trim(array_pop($matches));
|
||||||
}
|
}
|
||||||
if(strpos($newurl,'/') === 0)
|
if(strpos($newurl,'/') === 0)
|
||||||
$newurl = $url . $newurl;
|
$newurl = $old_location_info["scheme"]."://".$old_location_info["host"].$newurl;
|
||||||
if (filter_var($newurl, FILTER_VALIDATE_URL)) {
|
if (filter_var($newurl, FILTER_VALIDATE_URL)) {
|
||||||
$redirects++;
|
$redirects++;
|
||||||
return fetch_url($newurl,$binary,$redirects,$timeout);
|
return fetch_url($newurl,$binary,$redirects,$timeout);
|
||||||
|
|
Loading…
Reference in a new issue