Prevent hotlinking from unauthorized domains

#1
Well, I've been battling this for a bit, and had gone back to nginx because I had some sites hotlinking stuff that they had not asked permission to do. With nginx, I was able to give them a nice litte replacement graphic instead of what they thought they were getting. :whistle:

To stop hotlinking except from domains you allow, you simply need to place this in your rewrite box

Code:
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?twowheeldemon\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?gl1800riders\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?servinglinux\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?xenforo\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ images/hotlink-warning.jpg [L]
Just replace the domain names (twowheeldemon, gl1800riders, etc) with domains you want to allow and then point the images/hotlink-warning.jpg at an image you want to use that exists on your server. Should work a treat.
 
Top