CMOS checksum error-defaults l workaround for PHP curl to get 301 or 302 turn URL problems

Source: Internet
Author: User
To get the remote file using the PHP curl, the code is as follows:

Copy the Code code as follows:


$ghurl = Isset ($_get[' id ')? $_get[' id ']: ' http://www.baidu.com/';
PHP get
function getcontents ($url) {
$header = Array ("referer:http://www.baidu.com/");
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, $url);
curl_setopt ($ch, Curlopt_timeout, 30);
curl_setopt ($ch, Curlopt_httpheader, $header);
curl_setopt ($ch, curlopt_followlocation,1); Whether to crawl the page after the jump
Ob_start ();
Curl_exec ($ch);
$contents = Ob_get_contents ();
Ob_end_clean ();
Curl_close ($ch);
return $contents;
}
$contents = getcontents ($ghurl);
Echo $contents;
?>


Generally in Win2003+iis under the example, the Php_curl.dll configuration is OK.
But the author in Linux+apahe2.0+php5.2.12+directadmin, (General foreign host is used this configuration) if the URL gets 301/302 jump, will error:
curl_setopt () [function.curl-setopt]: curlopt_followlocation cannot be activated when in Safe_mode or a open_basedir is s ET in * * *
On this issue, Google, Baidu, are in the big article long Chinese, not proficient in Linux is really headache.
The solution is really simple: log in to your directadmin
Find->> "PHP safemode Configuration"-->> see

With the default Safe and Defaults Open BaseDir off, the problem is solved.

The above describes the CMOS checksum error-defaults l about PHP curl to get 301 or 302 of the URL problem of the solution, including the CMOS checksum error-defaults L aspects of the content, You want to be helpful to a friend who is interested in PHP tutorials.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.