A Simple Way to Stop Bandwidth Theft from Your Website

Boosting online traffic is one of the main goals for virtually every website on the Internet. A conscientious site owner, seeking to optimize performance, will regularly check detailed traffic logs available through their hosting account or a third-party service, like Google Analytics.

One very big potential problem that can be quickly detected involves the unauthorized use of files from your website by another Internet property. You must be watchful for this practice, especially if your site contains a lot of attractive image files, because it can significantly inflate traffic figures very quickly.

When checking website traffic data, review the amount of bandwidth that has been consumed for the current month. Bandwidth represents cumulative file usage. The set amount per month should not be exceeded. If it is, site visitors will be treated to a page displaying a warning message that the bandwidth limit has been exceeded. They will not be able to access any areas of the site.

Needless to say, this situation needs to be quickly remedied by either increasing the existing bandwidth limit, or by purchasing more from your hosting company. The latter option can be very expansive, so it behooves every site owner to ensure that he or she is getting the ‘most bang for the buck’ in terms of visitor usage.

It can, therefore, be a heart-stopper when you log in during the first week of the month, and find out that, say, over 40% of your assigned bandwidth has already been consumed.

Given that trend, you will very likely run out before the end of the month. Further investigation is needed. First, check the stats for the Referral Sites to see if an inordinate amount of visitors came from one specific URL outside if your own domain.

Then, look closely at which specific files have been most accessed by visitors. If an attractive image file happens to be one of them, it may mean that you’ve become the victim of bandwidth theft, and that the high traffic number is partially being generated by another site that has posted a direct link to your image.

If the other site attracts a large volume of traffic, such as an active message board or social media site, it will cause a tremendous spike in your monthly bandwidth transfer total. This practice is known as ‘hotlinking’.

In short, it means that lots of precious bandwidth is being burned up with virtually no benefit to you. Instead, an unscrupulous site owner is using your image(s) to adorn his or her site. It also may be that a poster to a message board has hotlinked to your image, a development that the other site owner might be unaware of.


The solution to the problem of hotlinking is a properly constructed ‘.htaccess’ file. This file, which is utilized to limit online access to certain site components, sits in your site’s root (main) directory.

To create the file, open a basic text editor like Notepad (Windows), or TextEdit (Mac). Copy a designated group of lines into the file, depending on your need, and paste them into an empty text file, as outlined below:

1) To stop hotlinking of any site images by displaying a replacement graphic when someone tries to do so, copy and paste the following lines.

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ http://i.imgur.com/qX4w7.gif [L]

Replace ‘mysite’ in the second line with your own URL. If your domain ends in ‘.net’ or ‘.org’ instead of ‘.com’, change that as well.

Save the file as htaccess.txt, and place it in the first hierarchal line of the stored website on your hard drive – the same line as your index (home page) file.

Upload the file to your server, then rename the txt file to .htaccess in your online directory.

After the adjustment to the .htaccess file name, a would-be hotlinker will see a graphic displayed on his or her site that states, “Warning: Do not hotlink images and steal bandwidth”, instead of your image file.

2) To prevent hotlinking from specific outside domains only, such as facebook.com, blogspot.com or myspace.com, but allow any other web site to hotlink images, utilize:

RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?facebook\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?blogspot\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?myspace\.com/ [NC]
RewriteRule .*\.(jpe?g|gif|bmp|png)$ http://i.imgur.com/qX4w7.gif [L]

As many domains as you like can be added to this expression. Every RewriteCond line should end with the [NC,OR] code, except the last one.

Website owners should be vigilant about checking for bandwidth theft. Once detected, a properly constructed .htacces file will permanently prevent this issue from occurring.

Home CSS Deals HTML HTML5 Java JavaScript jQuery Miscellaneous Mobile MySQL News PHP Resources Security Snippet Tools Tutorial Web Development Web Services WordPress