I am trying to get the redirect location of a website
When I make a cURL request, I get a 405 Not Allowed
code in the response.
Using SEOBook.com's Server Header Checker the response is 200 OK
.
In my tests I only found web-sniffer.net to get the expected 301 Moved Permanently
status in the response.
I have tried a lot of different cURL configurations (user agent, cookies...) but no combination so far has been able to get the response I was expecting.
My code :
<?php
$url = "https://www.indiegogo.com/projects/over-and-above-africa-the-solution-to-end-poaching-drones";
$timeout = 30;
$http = curl_init($url);
curl_setopt($http, CURLOPT_RETURNTRANSFER, true);
curl_setopt($http, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($http, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; fr; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13');
curl_setopt($http, CURLOPT_FRESH_CONNECT, true);
curl_setopt($http, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($http, CURLOPT_TIMEOUT, $timeout);
curl_setopt($http, CURLOPT_CONNECTTIMEOUT, $timeout);
if (preg_match('`^https://`i', $url))
{
curl_setopt($http, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($http, CURLOPT_SSL_VERIFYHOST, 0);
}
curl_setopt($http, CURLOPT_HEADER, true);
curl_setopt($http,CURLOPT_HTTPHEADER,array('Accept-Language', 'nl,en;q=0.7;en-us;q=0.3'));
$sContenu = curl_exec($http);
echo curl_getinfo($http, CURLINFO_HTTP_CODE);
curl_close($http);
echo $sContenu;
?>