|
If your website is image intensive and you have good quality images displayed, chances are that other people are stealing
bandwidth (hotlinking) and displaying your images on their website. They could be serveing your content to their visitors by linking to your objects from their web pages. For example, www.rouge.com might have some html on their site like
<img src=http://www.yoursite.com/picture.gif>
Hence for every visitor to rouge.com, yoursite.com would serve an image. This image would be out of context from your website, and the rouge.com visitor would never know the image was coming from
yoursite.com and would not visit yoursite.com. This is also known as "hotlinking".
The reason hotlinking is bad, aside from theft of copyright, is because those visitors from rouge.com are using up yoursite's bandwidth allowance. If there is enough traffic at rouge.com, then yoursite.com could end up being charged a lot of money for bandwidth usage that went to the benefit of rouge.com.
This type of bandwidth theft can happen with any media type, not just images, such as zip, pdf, swf, wav, mov, mp3.
There are several things you can do to prevent people from hotlinking to your property and to prevent them from using your bandwidth to serve their visitors at some other website.
If you want to block all websites other than your own from serving objects (images, flash files, etc) from your site, then you can use the following mod_rewrite rules in a file named .htaccess (include the period in the filename). The rules will protect all files in the same directory as the .htaccess file, as well as all directories below the one that contains the .htaccess file. The .htaccess file must be a plain text file in ascii format, which means if you write the file on your own computer, you should write it in Notepad or another plain text editor (NOT MS Word) and then if you FTP the file to the server, transfer it in ASCII mode, not BINARY mode.
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://yoursite.com [NC]
RewriteCond %{HTTP_REFERER} !^http://www.yoursite.com [NC]
RewriteRule .*\.(gif|jpg|swf|png)$ - [NC,F]
The above should be on separate unbroken lines (even though the lines may have wrapped in your browser window) where each newline begins "Rewrite....", and you need to replace "yoursite.com" with the domain name of your own website. If you have multiple
domains or serve your other domains with images from this site, then include them as a RewriteCond as well.
To block only a few specific sites from hotlinking your objects, you would do the following instead:
RewriteEngine On
RewriteCond %{HTTP_REFERER} rouge.com [OR,NC]
RewriteCond %{HTTP_REFERER} rouge2.com [OR,NC]
RewriteCond %{HTTP_REFERER} rouge3.com [NC]
RewriteRule .*\.(gif|jpg|swf|png)$ - [NC,F]
The above should be on separate unbroken lines (even though the lines may have wrapped in your browser window) where each newline begins "Rewrite...."
Also in both of the above examples, you could also change filename extensions (gif, jpg, swf) to other file extensions, or add other extensions to the list (like mp3, zip) as appropriate.
An alternative is to serve an image or object of your choice to visitors of rouge.com instead of the object that rouge.com was trying to steal. This is done by replacing only the last line in either of the above examples with:
RewriteRule .*\.(gif|jpg)$ http://yoursite.com/bad-image.gif [R,NC]
all on 1 unbroken line.
Then, if rouge.com was hotlinking to a GIF or JPEG from you, visitors of rouge.com will see bad-image.gif (which could be an image that says "Visit yoursite.com to see this image") instead of any other file that ended in .gif or .jpg. Doing this will still cost you bandwidth since you will continue to serve objects for the other site, just not the ones they wanted, and in due course they will stop.
|