如何保护图像被热链接?图像、链接

由网友(嘴角带伤,依旧微笑)分享简介:我曾尝试以下code htaccess的从被盗链停止我的图像,但它不能正常工作。I have tried the below code in htaccess to stop my images from being hotlinked, but it is not working.SetEnvIfNoCase R...

我曾尝试以下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盗链重定向 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

阅读全文

相关推荐

最新文章