cURL , get redirect url to a variable
You would use
curl_setopt($CURL, CURLOPT_HEADER, TRUE);
And parse the headers for the location
header
Easy way to find the redirected url (if you don't want to know in advance)
$last_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);