apache 图片防盗链

RewriteEngine on
RewriteCond %{HTTP_REFERER} !ot.com         [NC]
RewriteCond %{HTTP_REFERER} !baidu.com     [NC]
RewriteCond %{HTTP_REFERER} !soso.com         [NC]
RewriteCond %{HTTP_REFERER} !google.com     [NC]
RewriteCond %{HTTP_REFERER} !sogou.com     [NC]
RewriteCond %{HTTP_REFERER} !youdan.com     [NC]
RewriteCond %{HTTP_REFERER} !yahoo.cn         [NC]
RewriteCond %{REQUEST_URI}  !logo.png     [NC]
RewriteRule .*\.(jpg|png|gif|jpeg)$ http://www.ot.com/logo.png [R,NC,L]

 

假设我自己的域名是 www.ot.com,两关键的地方:

1)!ot.com ,http_referer(来源) 非 ot.com 域名访问时重写;

2)!logo.png ,request_uri(链接) 非 logo.png 图片时重写,如果这个图也重写的话,会变成死循环的!!!

posted @ 2017-01-12 11:41  Tiac  阅读(185)  评论(0编辑  收藏  举报