This is resolved... here is how I did it..
In order to read the headers as a string before the script redirected I used the following settings:
CURLOPT_HEADER, 1 (to output headers)
CURLOPT_RETURNTRANSFER, 1 (to return the headers as a string when using curl_exec)
CURLOPT_FOLLOWLOCATION, 0 (to disable following the header location in external script)
Explode headers into an array
$result = curl_exec($ch);
$headers = explode("\n", $result);
Loop headers and redirect manually
foreach($headers as $header) {
if (preg_match("/Location/i", $header)) {
header("{$header}");
}
}
Does anyone have any ideas or suggestions on how to do this better? It works as desired as is 😉