Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/241.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用curl在下载文件中重定向Https_Php_Redirect_Curl - Fatal编程技术网

Php 使用curl在下载文件中重定向Https

Php 使用curl在下载文件中重定向Https,php,redirect,curl,Php,Redirect,Curl,我有卷曲的问题。我尝试从另一台服务器下载文件。脚本仅下载此内容: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Site</title> <link rel="icon" type="image/ico" href="favicon.ico" />

我有卷曲的问题。我尝试从另一台服务器下载文件。脚本仅下载此内容:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Site</title>
<link rel="icon" type="image/ico" href="favicon.ico" />
<script type="text/javascript">
    if ('https:' !== location.protocol) location.replace(location.toString().replace(location.protocol, 'https:'));
</script>
<script type="text/javascript" src="src/includes.js"></script>
<link rel="search" type="application/opensearchdescription+xml" href="xml/search.xml"/>
</head>
<body>
<script type="text/javascript">
    if (!location.hash || '_=_' == location.hash) location.replace('/#' + location.pathname + location.search);
</script>
<noscript>
    <meta http-equiv="refresh" content="0;?nojs" />
    <a href="?nojs">HTML only version</a>
</noscript>
</body>
</html>

谢谢您的帮助。

您提供的html中的JS脚本将
http
协议替换为
https
。您的php脚本应该模拟此操作。但事实并非如此,因为您混淆了
str\u replace
调用中参数的顺序
str_replace('https://'、'http://'、$workerLocation)
旨在将'https://'替换为'http://'。但是你需要做相反的操作

因此,您必须确定参数的顺序:

$ch = curl_init(str_replace('http://', 'https://', $workerLocation));

从选项列表中删除(注释)
CURLOPT\u SSL\u VERIFYHOST
选项我更改了它,但得到了相同的错误我在输入页面上没有问题,但在第一次重定向之后。我需要更换遥控器,但问题仍然存在。
$ch = curl_init(str_replace('http://', 'https://', $workerLocation));