解决方案:由于连接不安全(混合内容),PHP文件下载被Chrome阻止

解决方案:由于连接不安全(混合内容),PHP文件下载被Chrome阻止,php,google-chrome,https,http-headers,mixed-content,Php,Google Chrome,Https,Http Headers,Mixed Content,我有几个项目的文件下载不再工作了。这似乎是由于最近Chrome政策的改变 下载尝试失败,控制台中出现此错误: Mixed Content: The site at 'https://example.com/' was loaded over a secure connection, but the file at 'https://example.com/logs_view.php?export=true' was redirected through an insecure connectio

我有几个项目的文件下载不再工作了。这似乎是由于最近Chrome政策的改变

下载尝试失败,控制台中出现此错误:

Mixed Content: The site at 'https://example.com/' was loaded over a secure connection, but the file at 'https://example.com/logs_view.php?export=true' was redirected through an insecure connection. This file should be served over HTTPS. This download has been blocked. See https://blog.chromium.org/2020/02/protecting-users-from-insecure.html for more details.
我的文件通过PHP提供:

header("Content-Type: application/xls");
header("Content-Disposition: attachment; filename=".$filename.".xls");  
header("Pragma: no-cache"); 
header("Expires: 0");
echo utf8_decode($export);
似乎此方法不发送带有HTTPS头的文件。。。你知道怎么解决这个问题吗

您可以在下面找到服务器响应标头的标头:

HTTP/1.1 200 OK
Date: Tue, 19 Jan 2021 11:33:14 GMT
Server: Apache
Expires: 0
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Content-Disposition: attachment; filename=base_changelog_2021-01-19_12-33-14.xls
Content-Length: 899
Keep-Alive: timeout=5, max=92
Connection: Keep-Alive
Content-Type: application/xls
非常感谢你的支持


Ben

我找到了一种方法,强迫chrome“升级”下载

我在我的.htaccess中添加了这个调整,它成功了

<ifModule mod_headers.c>
Header always set Content-Security-Policy "upgrade-insecure-requests;"
</IfModule>

标头始终设置内容安全策略“升级不安全请求