How to stop bandwidth stealing with htaccess file

By -

Bandwidth Stealing or Hotlinking is a scenario when somebody uses a file from your site directly to his. This results in consumption of your bandwidth. Many people does not realize but this is a common problem and as there is no direct way to know about it, we never get to know about it. This scenario can not only lead to your hosting banning your site as its out of bandwidth but your content is getting stolen too. If you want  you can read about Top Five Ways to stop content stealing

What is hot linking?

Hot linking is a scenario where some other site uses files hosted on your site. This results in bandwidth stealing as every time the hot linked page is viewed, images or files are requested from your server hence your bandwidth is use.

How to find if my files are hotlinked ?

There is no direct way, But when I asked my hosting about it, they said we can check our web stats and find out how much bandwidth is being used by which page or other things. If you something very high try to find out where it is linked.

How to stop hotlinking using .htaccess file ?

This can be helpful for PHP based site and wordpress based sites.

Before you write your own rules, enable the hot linking protection enabled and then write into .htaccess file. I did it reverse and my site gave Error 500. Be Careful. In case if something goes wrong just remove the .htaccess file and replace with original one ( Did I forgot to say backup your .htaccess file first ? Please do it ) and be sure mod_rewrite is enabled. Ask your hosting about it.

There are three ways of doing it.

  1. Ban all hotlinkers
  2. Ban one particular hotlinker
  3. Show a different image to one particular hotlinker

I followed the second step as I came to know who was stealing my content. Here is the code I used


# BEGIN WordPress

RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://xxx.com/.* [NC]
RewriteRule \.(gif|jpg|js|css|JPG)$ - [F]

# END WordPress

You can replace xxx with the site who is stealing your bandwidth and in second line you can restirct files by extension or types. Remember This is to just avoid one hot linker.

Here is the link to complete guide of all the three scenarios. Stop Image Hotlinking using .htaccess and this article How Do I Stop Hotlinking and Bandwidth Theft? can explain you meaning of each line and terms being used. I would recommend using the first link for implementing the code and second to understand it better. ( I got some problem while using the code from second article)

I don’t have PHP based Site or WordPress What should I do?

Not sticking to just wordpress but every hosting has Hot Link Protection feature. You can query your hosting about it and ask how to enable it. Just remember, you should allow your site url to access it.

Since I faced this problem, I wanted to share it with you all. I hope this helps many others.



A Professional Tech blogger, Editor and Writer who talks about solving day to day problems of people who use computer. His expertise are in Windows 7, Microsoft Office, Software, Mobile Apps and Video Posts. You can find Ashish on , and .

Leave a Reply

Stats