One quick and easy trick in Apache to block users from leaching your images (or other files) from your web space is with mod_rewrite; the rule I'm going to share with you today will block image leachers and file leachers from raiding your bandwidth.
Each site you wish to add will have its own line, and will be prefixed by "RewriteCond %{HTTP_REFERER} !"
Blocking Image Hotlinkers .htaccess entry:
# Start UGN Specific Hosts #
RewriteCond %{HTTP_REFERER} !38.99.95.240 [NC]
RewriteCond %{HTTP_REFERER} !38.99.95.222 [NC]
RewriteCond %{HTTP_REFERER} !undergroundnews.com [NC]
RewriteCond %{HTTP_REFERER} !undergroundnews.net [NC]
RewriteCond %{HTTP_REFERER} !undergroundnews.org [NC]
# Start Affiliate Hosts #
RewriteCond %{HTTP_REFERER} !ubbdev.com [NC]
RewriteCond %{HTTP_REFERER} !ubbcentral.com [NC]
# Start Search Engine Hosts #
RewriteCond %{HTTP_REFERER} !google.com [NC]
RewriteCond %{HTTP_REFERER} !yahoo.com [NC]
RewriteCond %{HTTP_REFERER} !picsearch.com [NC]
RewriteCond %{HTTP_REFERER} !^http://aolsearch.aol.com [NC]
# Start defined files & redirect location #
RewriteRule [^/]+.(jpeg|jpg|gif|bmp|png|JPEG|JPG|GIF|BMP|PNG)$ - [F]
This will block all users linking to the file types ".gif", ".jpg", ".jpeg", ".psd", ".png"; they will receive a red X when trying to link to your graphics.
You can forward them to another graphic of your choosing as well by replacing the image rule at the bottom of the above example with:
RewriteRule [^/]+.(jpeg|jpg|gif|bmp|png|JPEG|JPG|GIF|BMP|PNG)$ http://www.yoursite.tld/nofreelinking.gif [F]
You can use the above rules to also block hotlinking to files by using:
RewriteRule [^/]+.(exe|com|swf|fla|mp3|mov|wmv|rm|ram|wma|zip|txt|bat|tar|rar|gz|tgz)$ - [F]
And you can additionally use it to block BOTH files and graphics with:
RewriteRule [^/]+.(exe|com|swf|fla|mp3|mov|wmv|rm|ram|wma|zip|txt|bat|tar|rar|gz|tgz|gif|jpg|jpeg|psd|png)$ - [F]
The hosts section has separate sections for your site hosts (for sites with more than one domain), affiliate hosts (so you can allow your affiliates to grab your content), and for search engines (so Google images can grab copies of your files to show in an image search).