title: Get cURL to follow redirects
body: <p>I have an application in Laravel that scrapes sites and retrieves specific information.
  Lately I've been seeing more and more sites getting 403 forbiidden so i decided to try cURL out for the first time.</p>
  
  <p>The only problem i have now, is that sites that have 301 or 302 redirects, cURL doesn't follow them.</p>
  
  <p>This is what I have:</p>
  
  <pre><code>$curl = curl_init(); 
          curl_setopt($curl, CURLOPT_URL, $results['url_search']);  
          curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);  
          curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);  
          curl_setopt($curl,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
  
          $str = curl_exec($curl);  
  
          $header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
          $header = curl_getinfo($curl, CURLINFO_HTTP_CODE);
          $body = substr($str, $header_size);
  
          curl_close($curl); 
  </code></pre>
  
  <p>So as I said, on pages where there are redirects, I get stuck. Any suggestions?
  I've seen some things but none of them worked.</p>