--------------------------------------------------------------------------------
Preventing hot linking of images
--------------------------------------------------------------------------------
In the webmaster community, "hot linking" is a curse phrase. Also known as "bandwidth stealing". It refers to linking directly to non-html objects not on one own's server, such as images, .js files etc. The victim's server in this case is robbed of bandwidth (and in turn money) as the violator enjoys showing content without having to pay for its deliverance. The most common practice of hot linking pertains to another site's images.
How can I prevent people from hotlinking to my images?
The best way to stop hot linking is to have your images placed in a seperate folder (not the same folder as your html files) and put a .htaccess file in it. Each folder should also have a blank index.html file to prevent people from seeing your directory listing.
In order for the method below to work, the browser that requests the page must return the URL of the page, called the "HTTP_REFERER". Checking the HTTP_REFERER will slow down the server somewhat so you should only do this if people hotlinking your images is a problem.
Copy this text below, make the changes to show your domain info, and paste it into notepad. Name this file .htaccess and place it in all your image folders. Be sure to upload in ASCII mode or the .htaccess file will not work.
Text Formatted Code
Options All
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ - [F]
Be sure to replace "mydomain.com" with your own. The above code causes a broken image to be displayed when its hot linked. You can have an image display for those who try to hot link. You can have an image of your choice be displayed for those attempting to steal bandwidth. The code for this is:
Text Formatted Code
Options All
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ http://www.mydomain.com/notallowed.gif [R,L]
The first line allows the "RewriteRule" directive to be used (only needed on some servers).
The next line tells Apache to turn on the MOD Rewite.
The next two lines you change to your address (either with, and without the www. as well as your IP).
The last line is where you would like the link from the site trying to download from their pages to be redirected. This way if some one links directly to your "coolpicture.jpg" from their website, instead of seeing your cool picture the user will see a picture that you decide to show. Make the picture be something the user will not want to see and get the message across that he is a bandwidth stealer. After the user sees that the "hot linking" isn't working, the user will change his links.
In order to have it work for you:
replace mydomain.com with your own domain
replace the notallowed.gif with the image you want them to see.
From the FAQ of my hosting provider:
Tera-Byte
Vanrillaer.com - our Family Portal