Jump to content

cURL


The Little Guy

Recommended Posts

Why when I use cURL, some sites display: The document has moved here.

 

My code:

			$url = $_GET['p'];
		$ch = curl_init();
		$timeout = 5; // set to zero for no timeout
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
		$file_contents = curl_exec($ch);
		curl_close($ch);

		// display file
		echo $file_contents;

Link to comment
https://forums.phpfreaks.com/topic/125033-curl/
Share on other sites

<?php
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
?>

 

It's possible the site has moved and apache is doing a header redirect to the page in question, but you don't have cURL enabled to follow it [off by default I believe].

 

edit: I remember when  I was testing my apache redirect stuff, I didn't even see the page change before I was at my destination because my browser followed so fast.

Link to comment
https://forums.phpfreaks.com/topic/125033-curl/#findComment-646126
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.