如何保护图像被热链接? [英] How to protect images from being hotlinked?

查看:124
本文介绍了如何保护图像被热链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾尝试以下code htaccess的从被盗链停止我的图像,但它不能正常工作。

I have tried the below code in htaccess to stop my images from being hotlinked, but it is not working.

SetEnvIfNoCase Referer "^http://www.example.com/" locally_linked=1
SetEnvIfNoCase Referer "^http://www.example.comm$" locally_linked=1
SetEnvIfNoCase Referer "^http://example.com/" locally_linked=1
SetEnvIfNoCase Referer "^http://example.com$" locally_linked=1
SetEnvIfNoCase Referer "^$" locally_linked=1
<FilesMatch "\.(gif|png|jpe?g|css|js)$">
  Order Allow,Deny
  Allow from env=locally_linked=1
</FilesMatch>

谁能帮助我如何prevent盗链?

Can anyone help me with how to prevent hotlinking?

推荐答案

这将显示一个固定的形象,只要它的热链接。 (该图像可能有盗链在不允许的消息......)

This will show a fixed image whenever its hotlinked. (That image may have a message that Hotlinking in not allowed...)

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain\.com [NC]
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpg [L]

它检查Refererr没有什么,引用者是不匹配的mydomain然后将其与图像响应 nohotlink.jpg

要了解盗链prevention更清楚地看到这些所谓主题:
的Apache的.htaccess盗链重定向
<一href="http://stackoverflow.com/questions/1775582/apache-hotlink-protection-for-download-folder?rq=1">Apache防盗链的下载文件夹
基础教程 http://altlab.com/htaccess_tutorial.html

To understand hotlinking prevention better see these SO threads:
Apache .htaccess hotlinking redirect
Apache Hotlink Protection for Download Folder
A Basic tutorial http://altlab.com/htaccess_tutorial.html

这篇关于如何保护图像被热链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆