title: cURL refuses to display 302 redirect URL
body: <p>Here's my code:</p>
  
  <pre><code>    $urls = array('http://www.avantlink.com/click.php?p=62629&amp;pw=18967&amp;pt=3&amp;pri=152223&amp;tt=df');
    $curl_multi = curl_multi_init();
    $handles = array();
  
    $options = $curl_options + array(
          CURLOPT_HEADER                  =&gt; true,
          CURLOPT_RETURNTRANSFER  =&gt; true,
          CURLOPT_NOBODY                  =&gt; true,
          CURLOPT_FOLLOWLOCATION  =&gt; true,
          CURLOPT_HEADERFUNCTION  =&gt; 'read_header',
          CURLOPT_USERAGENT               =&gt; 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36',
          CURLOPT_HTTPHEADER          =&gt; array(
              'Accept-Language: en-US,en;q=0.8',
              'Accept-Encoding: gzip,deflate,sdch',
              'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36',
              'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
              'Connection: keep-alive',
              'Host: www.avantlink.com',
          ));
  
    foreach($urls as $i =&gt; $url) {
      $handles[$i] = curl_init($url);
      curl_setopt_array($handles[$i], $options);
      curl_multi_add_handle($curl_multi, $handles[$i]);
    }
  
    $active = null;
      do {
          $status = curl_multi_exec($curl_multi, $active);
          sleep(1);
          error_log('loading redirect: '.$active.' left');
      }
      while (!empty($active) &amp;&amp; $status == CURLM_OK);
  
    do {
      $status = curl_multi_exec($curl_multi, $active);
    } while ($status == CURLM_CALL_MULTI_PERFORM);
  
    while ($active &amp;&amp; ($status == CURLM_OK)) {
      if (curl_multi_select($curl_multi) != -1) {
        do {
          $status = curl_multi_exec($curl_multi, $active);
        } while ($status == CURLM_CALL_MULTI_PERFORM);
      }
    }
  
    if ($status != CURLM_OK) {
      trigger_error("Curl multi read error $status\n", E_USER_WARNING);
    }
  
    $results = array();
    foreach($handles as $i =&gt; $handle) {
      $results[$i] = curl_getinfo($handle);
      curl_multi_remove_handle($curl_multi, $handle);
      curl_close($handle);    
    }
    curl_multi_close($curl_multi);
  </code></pre>
  
  <p>Here's what it gets me (from the read_header() function):</p>
  
  <pre><code>HTTP/1.1 200 OK
  Date: Mon, 18 Nov 2013 22:42:29 GMT
  Server: Apache
  Vary: Accept-Encoding,User-Agent
  Content-Encoding: gzip
  Content-Length: 20
  Keep-Alive: timeout=5, max=100
  Connection: Keep-Alive
  Content-Type: text/html; charset=UTF-8
  </code></pre>
  
  <p>If I print_r() the curl_getinfo() I get this:</p>
  
  <pre><code>Array
  (
      [url] =&gt; http://www.avantlink.com/click.php?p=62629&amp;pw=18967&amp;pt=3&amp;pri=152223&amp;tt=df
      [content_type] =&gt; text/html; charset=utf-8
      [http_code] =&gt; 200
      [header_size] =&gt; 247
      [request_size] =&gt; 402
      [filetime] =&gt; -1
      [ssl_verify_result] =&gt; 0
      [redirect_count] =&gt; 0
      [total_time] =&gt; 2.391713
      [namelookup_time] =&gt; 0.388584
      [connect_time] =&gt; 1.389628
      [pretransfer_time] =&gt; 1.389645
      [size_upload] =&gt; 0
      [size_download] =&gt; 0
      [speed_download] =&gt; 0
      [speed_upload] =&gt; 0
      [download_content_length] =&gt; 20
      [upload_content_length] =&gt; 0
      [starttransfer_time] =&gt; 2.391203
      [redirect_time] =&gt; 0
      [certinfo] =&gt; Array
          (
          )
  
  )
  </code></pre>
  
  <p>But if you go to that URL in chrome (or whatever) you'll see that the URL gives you a 302 redirect to <a href="http://www.alssports.com/product.aspx?pf_id=10212312&amp;avad=18967_b55919f9" rel="nofollow">http://www.alssports.com/product.aspx?pf_id=10212312&amp;avad=18967_b55919f9</a>. I need it to give me the alssports.com url. I've been working on this code for almost the entire day. What am I doing wrong?</p>