Page 1 of 1

PHP cURL and inconsistent redirect visibility

Posted: Fri Dec 17, 2010 5:55 pm
by Engineerd
Hi Team,

My Goal... to process all redirects serverside and simply return the LP url to the client so that no visibility occurs during redirection.

Code: Select all

$ch2 = curl_init();	
			curl_setopt($ch2,CURLOPT_URL,$url);
			curl_setopt($ch2, CURLOPT_FOLLOWLOCATION, true);
			curl_setopt($ch2,CURLOPT_POST,'');
			curl_setopt($ch2,CURLOPT_POSTFIELDS,'');
			curl_exec($ch2);
			curl_close($ch2);
The above is what I'm currently using. Sometimes it works like a charm, sometimes it doesn't... even if I include my function:
util_redirect(get_final_url($url)); at the end...

Code: Select all

function get_final_url($url){
    global $final_host;
  	$redirects = get_all_redirects($url);
  	if (count($redirects)>0){
  	  $final_url = array_pop($redirects);
  	  if(substr($final_url,0,7) != 'http://' && !empty($final_host))
  	    { $final_url = 'http://'.$final_host.$final_url; }
  		return $final_url;
  	} else {
  		return $url;
  	}

Any help :( I'm totally stuck.... all redirection MUST happen server-side.