404 not found in curl

I searched for an answer here around 404, but I was not lucky to solve my problem. I have the same problem in a previous post. I already copy and paste my answer, but no longer carry.

here is my code

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT,"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1" );
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$raw_data = curl_exec($ch);
curl_close($ch);

var_dump($raw_data);

I do not know if I have the correct code in curl. But if I paste the URL into the browser, I get the result. Is there something I need to configure or install on my server? I don’t know what is the reason for this. Do I need to use the server staff to verify this? I hope for your advice. I am new to this.

0
source share
1 answer

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); . , URL- ( http https, domain.com www.domain.com ..), .

. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);, !

+2

All Articles