Return to Snippet

Revision: 51810
at October 5, 2011 01:33 by sybrex


Initial Code
$url = 'http://google.com';
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);

$header = "Location: ";
$pos = strpos($response, $header)+strlen('Location: ');
$redirect_url = substr($response, $pos, strpos($response, "
", $pos)-$pos);

Initial URL

                                

Initial Description

                                

Initial Title
Get page redirect URL

Initial Tags
curl, php, redirect

Initial Language
PHP