cURL on local dev network problem with virtual host naming

前端 未结 1 2035
栀梦
栀梦 2020-12-18 11:05

Trying to do some local testing on a virtual server, the problem is cURL is returning a http_code => 0

I think it\'s to do with my virtual host naming.

Virtu

相关标签:
1条回答
  • 2020-12-18 12:03

    If anyone has this issue, here is the fix:

    // This is your Virtual Hosts name
    $request_host   = 'dev.project'; 
    
    // This is the IP
    $request_url    = '192.168.0.1';
    
    $headers = array("Host: ".$request_host);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);     
    curl_setopt($ch, CURLOPT_URL, $request_url.'?'.$request_args);
    curl_setopt($ch, CURLOPT_HEADER, FALSE);
    
    0 讨论(0)
提交回复
热议问题