oder man nutzt es direkt mit der richtigen curl option dafür

Code:
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);