2014-01-10 38 views
1
RewriteCond %{HTTP_REFERER} !^http://website.net/.*$  [NC] 
RewriteCond %{HTTP_REFERER} !^http://website.net$  [NC] 
RewriteCond %{HTTP_REFERER} !^http://www.website.net/.*$  [NC] 
RewriteCond %{HTTP_REFERER} !^http://www.website.net$  [NC] 
RewriteRule .*\.(jpg|jpeg|gif|png|bmp|rar)$ http://website.net/news.php [R,NC] 

这就是我目前使用的(从我的cPanel自动生成的)。仅针对特定网站的热链接防护

有没有一种方法可以让我只从某个网站启用这种热链接保护功能,例如: site.com

或者另一种选择是disabe它某些网站 - trustedsite1.comtrustedsite2.com

任何该等两个选项非常适合我。

回答

1

要对来自特定站点阻止盗链:

RewriteCond %{HTTP_REFERER} ^https?://site.com$  [NC] 
RewriteRule .*\.(jpg|jpeg|gif|png|bmp|rar)$ http://website.net/news.php [R,NC] 

要允许从trustedsite1和trustedsite2,只需添加附加条件:

RewriteCond %{HTTP_REFERER} !^http://website.net/.*$  [NC] 
RewriteCond %{HTTP_REFERER} !^http://website.net$  [NC] 
RewriteCond %{HTTP_REFERER} !^http://www.website.net/.*$  [NC] 
RewriteCond %{HTTP_REFERER} !^http://www.website.net$  [NC] 
RewriteCond %{HTTP_REFERER} !^http://trustedsite1.com/.*$  [NC] 
RewriteCond %{HTTP_REFERER} !^http://trustedsite2.com/.*$  [NC] 
RewriteRule .*\.(jpg|jpeg|gif|png|bmp|rar)$ http://website.net/news.php [R,NC] 
+0

正是我一直在寻找,真的很感激:-) – Nikola