{"id":320,"date":"2015-02-23T15:24:25","date_gmt":"2015-02-23T23:24:25","guid":{"rendered":"http:\/\/shanelabs.com\/blog\/?p=320"},"modified":"2015-02-23T15:24:25","modified_gmt":"2015-02-23T23:24:25","slug":"does-curl-follow-redirects-by-default","status":"publish","type":"post","link":"https:\/\/shanelabs.com\/blog\/2015\/02\/23\/does-curl-follow-redirects-by-default\/","title":{"rendered":"Does CURL follow redirects by default?"},"content":{"rendered":"<p>What happens when PHP&#8217;s CURL library\u00a0encounters a 301 Redirect header? It depends.<\/p>\n<p><strong>By default, it does NOT redirect.<\/strong> It will simply halt after the header is returned.<\/p>\n<p>However, there is an option you can set that allows it to follow up to 5 redirects in a chain: the\u00a0CURLOPT_FOLLOWLOCATION setting.<\/p>\n<blockquote>\n<pre><span class=\"nb\">curl_setopt<\/span><span class=\"p\">(<\/span><span class=\"nv\">$curl<\/span><span class=\"p\">,<\/span> <span class=\"nx\">CURLOPT_FOLLOWLOCATION<\/span><span class=\"p\">,<\/span> <span class=\"k\">true<\/span><span class=\"p\">);<\/span><\/pre>\n<\/blockquote>\n<p>Hope that helps anyone else out there that was curious!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What happens when PHP&#8217;s CURL library\u00a0encounters a 301 Redirect header? It depends. By default, it does NOT redirect. It will simply halt after the header is returned. However, there is an option you can set that allows it to follow up to 5 redirects in a chain: the\u00a0CURLOPT_FOLLOWLOCATION setting. curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); Hope that helps [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-320","post","type-post","status-publish","format-standard","hentry","category-software"],"_links":{"self":[{"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/posts\/320","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/comments?post=320"}],"version-history":[{"count":1,"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/posts\/320\/revisions"}],"predecessor-version":[{"id":321,"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/posts\/320\/revisions\/321"}],"wp:attachment":[{"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/media?parent=320"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/categories?post=320"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/tags?post=320"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}