是的,它不会出现,因为其他服务器正在阻止图像的热链接。
一个典型的例子是
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yande.re/.*$ [NC]
RewriteRule \.(gif|jpg|js|css)$ - [F]
解决方案。
- 通过 curl 加载图像
- 保存到 CDN
- 然后将其显示在您的网站上
概念证明
$url = 'https://yande.re/sample/2f7b6c5d87d90f173769d999e60861c8/yande.re%20250521%20sample.jpg';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.43 Safari/537.31");
curl_setopt($ch, CURLOPT_REFERER, "https://yande.re");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$data = curl_exec($ch);
curl_close($ch);
// $data is file data
$post = array('image' => base64_encode($data), 'key' => "YOUR_API_KEY_ITS_FREE");
$timeout = 30;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://api.imgur.com/2/upload.json');
curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
$json = curl_exec($curl);
curl_close ($curl);
$json = json_decode($json);
printf("<img src\"%s\" / >",$json->upload->links->small_square);
输出