I know this has been covered many places elsewhere, but I thought I'd share since I just dealt with this issue on one of my sites.
For those not familiar with the topic, hotlinking/leeching of files can be a huge issue on websites - people eat up your bandwidth by linking directly to a file on your site, rather than host the file themselves. Some people don't care much about the habit, but some do, especially if it gets to the point where you're paying overages.
There are several ways to combat this practice, one of the best is to use Apache's ".htaccess" files to redirect requests for files from off-site to nothing, or a file of your choosing. Here's what I did:
This file allows me to still hotlink images from MacRumors and my site, but redirect anything else to this image:
- It's less than 1Kb and should get people to my site directly.
Note: In order to get it to work right, the file you redirect to can't be in the same directory as the .htaccess file - it'd be trying to redirect to itself. I put my .htaccess in my images directory and the "leech.gif" file at the root level. You'll also need to restart Apache to get the changes to take effect.
Pretty simple and effective.
For those not familiar with the topic, hotlinking/leeching of files can be a huge issue on websites - people eat up your bandwidth by linking directly to a file on your site, rather than host the file themselves. Some people don't care much about the habit, but some do, especially if it gets to the point where you're paying overages.
There are several ways to combat this practice, one of the best is to use Apache's ".htaccess" files to redirect requests for files from off-site to nothing, or a file of your choosing. Here's what I did:
Code:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?organicallydigital.com.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?macrumors.com.*$ [NC]
RewriteRule .*[Jj][Pp]?[Gg]$|.*[Gg][Ii][Ff]$|.*[Pp][Nn][Gg]$ leech.gif [R,L]
This file allows me to still hotlink images from MacRumors and my site, but redirect anything else to this image:

Note: In order to get it to work right, the file you redirect to can't be in the same directory as the .htaccess file - it'd be trying to redirect to itself. I put my .htaccess in my images directory and the "leech.gif" file at the root level. You'll also need to restart Apache to get the changes to take effect.
Pretty simple and effective.