2014-01-10 41 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