Enable Hotlink Protection for Specific Sites

If you read my previous post on hotlinking, you may be wondering how you can block these offending sites. Often, enabling hotlink protection will break your newsletters and feeds, so I recommend blocking individual sites.

To block specific sites:

  1. Open up your cPanel and visit the File Manager once again. This time, select Web Root in the pop up box. Also, check the "Show Hidden Files (dotfiles)" box.
  2. Web Root FTP
  3. Select the .htaccess file and click Edit. Click Edit again in the pop up box.
  4. Insert the following code at the very top of the file. Replace the domain as necessary. For example, if google.com were hotlinking your image, enter google.com
  5. # Hotlink Protection
    RewriteEngine On
    RewriteCond %{HTTP_REFERER} ^http://domainhere.com/ [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http://(.+\.)?domainhere\.com/ [NC]
    RewriteRule .*\.(jpe?g|gif|bmp|png)$ - [F]
  6. Repeat for other offending domains and save the file.

This is what the code has done. Here's the image before:

Hotlink Before

And here's what it looks like after:

Hotlink After

As you can see, the image is not being displayed, and is not using any bandwidth.

Don't know how to find out if your images are being hotlinked? You can find out through a simple AWStats hack.

Leave a Reply

Your email address will not be published. Required fields are marked *