Apache 如何防止图像被热链接?
我在htaccess中尝试了下面的代码来阻止我的图像被热链接,但它不起作用Apache 如何防止图像被热链接?,apache,.htaccess,hotlinking,Apache,.htaccess,Hotlinking,我在htaccess中尝试了下面的代码来阻止我的图像被热链接,但它不起作用 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
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>
setEnvifLocase引用器”^http://www.example.com/“本地链接=1
SetEnvifLocase Referer“^http://www.example.comm$“本地链接=1
SetEnvifLocase Referer“^http://example.com/“本地链接=1
SetEnvifLocase Referer“^http://example.com$“本地链接=1
SetEnvIfNoCase参考“^$”本地链接=1
命令允许,拒绝
允许来自环境=本地链接=1
有人能帮我防止热链接吗?这将在其热链接时显示固定图像。(该图像可能包含不允许热链接的消息…) 它检查referer是否为空,并且referer与mydomain不匹配,然后用image
nohotlink.jpg
响应
要更好地理解热链接预防,请参阅以下SO线程:基本教程这不允许任何热链接,除非引用者来自
example.com
SetEnvIf Referer example\.com localreferer
<FilesMatch \.(jpg|png|gif|css|js|pdf|doc|xls|txt)$>
Order deny,allow
Deny from all
Allow from env=localreferer
</FilesMatch>
setenif Referer示例\.com localreferer
命令拒绝,允许
全盘否定
允许来自env=localreferer
你的意思是热链接。如果你根本不想保存图像,你就必须让它完全远离互联网。我不知道apache,但最后一个是否应该本地链接=0?另外,在“允许”之后是否需要拒绝?如果不完全阻止链接,而是使用htaccess显示特殊的错误图像,则会更容易。@ankit如何显示错误图像我已经尝试了您提供的所有帮助链接。但事实并非如此working@Ankit:您的代码不允许从http://mydomain.com.otherdomain.com
SetEnvIf Referer example\.com localreferer
<FilesMatch \.(jpg|png|gif|css|js|pdf|doc|xls|txt)$>
Order deny,allow
Deny from all
Allow from env=localreferer
</FilesMatch>