简体   繁体   English

img http推荐人

[英]img http referer

When opening an image (thru <img> tag) using any of the major browsers the HTTP referer header is sent. 使用任何主要浏览器打开图像(通过<img>标记)时,都会发送HTTP引用标头。 I was trying setting src attribute to some https:// url (valid certificate, was hoping that going from secured to unsecured page will blank the referer) which then was redirecting to the target page (by Location header) and few other "methods", nothing seems to be working... any ideas please? 我正在尝试将src属性设置为某些https:// url(有效证书,希望从安全页面转到不安全页面将使引用无效),然后将其重定向到目标页面(通过Location标头)和其他一些“方法” ,似乎没有任何效果...请问任何想法?

If I understand, this could do the trick: 据我了解,这可以解决问题:

$opts = array('http' =>
    array(
        'method'  => 'GET',
        'header'  => 'Referer: http://example.com',
    )
);

$context  = stream_context_create($opts);

header('Content-Type: image/vnd.microsoft.icon');
echo file_get_contents($_GET['image_src'], false, $context);

And then in HTML: 然后在HTML中:

<img src="/path/to/file.php?image_src=http://www.google.com/favicon.ico" alt="">

Hope it helps. 希望能帮助到你。

Or rather just save the image to your own website. 或者只是将图像保存到您自己的网站。 Hotlinking images from different sites is generally considered bandwidth stealing by the netiquette. 来自不同站点的热链接图像通常被网络礼仪视为带宽窃取

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM