How to stop them from hotlinking your files

First and foremost, I would like to say thank you very much for those who gave me comments and suggestions to my last post. Here, I found two ways how you can prevent someone from hotlinking your files and eating up your bandwitdh.

1st Method – CPanel HotLink Protection

cpanel_logo.gifIf you use CPanel, you can set and block peoples from hotlinking your files with HotLink Protection option. Just login into your CPanel and click on the HotLink Protection icon. In the HotLink Protection page, you can set which urls you allow for access, file types that you want to protect, url to redirect the hotlinked files and option to allow direct request.

For more clear view about this, I have prepare you with a flash video on how to use the HotLink Protection option. I found this video from my hosting provider FAQ page.

2nd Method – .htaccess

You also can do this with .htaccess file on Apache web server if you don’t have CPanel. Here is how to do it:

  1. Create file name htaccess.txt
  2. Place this code in your htaccess.txt file

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

    What this code does is it will only allow hotlink files from your domain ( and direct request. And if it comes from other domain or request, files with extension .jpeg, .gif, .bmp and .png will be replaced with stophotlink.jpe file.

    Note: .jpe is a .jpg image file. We use .jpe because we want to prevent from infinite redirect loop.

  3. Upload htaccess.txt file into your root server
  4. Rename the file to .htaccess
  5. Done!

More info for this second method, you can read this tutorial, How Do I Stop Hotlinking and Bandwidth Theft?


  1. Nice info man . I had cpanel all along but didnt pay any attention to this .

  2. no problem. i just found out that this thing is good to share. 🙂

  3. Hi..i’m your new fun member..nice blog huh! i found load of information inside there..keep it up dude! of course for blogger out there!

  4. ha3. sure. thanks for your comment. 🙂