Categories
Uncategorized

Disable Hotlinking using htaccess to stop Bandwidth Theft without effecting your Feeds!

Hotlinking has to be disabled because when you are not an Unlimited Hosting Plan, or else this will surely effect the performance of your site. In the method depicted below you just have to add the extensions of the files that you want to prevent from hotlinking to the code given below. For example, if you want to prevent videos hosted on your site to be hotlinked, then you will have to add the extension of the video file type like mp4 or avi to the code after the gif extension.

Add the code shown below to your .htaccess file to prevent your images from being hotlinked. Just change the line that says ^http(s)?://(www\.)?thecollegestash.com [NC] according to your site URL and you are done. This method does not cause your Feeds from Feedburner to stop functioning by not displaying images from your site. The code listed below is the same as the code I use on this Site. It encourages almost all the social networking sites popular today like facebook, pinterest, etc to hotlink my images.

#Image hotlinking Protection [theCollegeStash.com]
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?thecollegestash.com [NC]
RewriteCond %{HTTP_REFERER} !google\. [NC]
RewriteCond %{HTTP_REFERER} !search\?q=cache [NC]
RewriteCond %{HTTP_REFERER} !msn\. [NC]
RewriteCond %{HTTP_REFERER} !yahoo\. [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?feedburner.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?feeds2.feedburner.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yahoo.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?msn.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?bing.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?facebook.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?pinterest.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?bloglines.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?feedly.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?netvibes.com/.*$ [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ – [NC,F,L]
#Image hotlinking Protection [theCollegeStash.com]

The .htaccess file is located in your root Directory. You have to download it to your system and then edit it using a text editor like Notepad and then Save the changes and upload the file back to the root Directory, replacing the original file.

There are other ways to prevent hotlinking  like installing the following plugin:
Configurable Hot Link Protection

Display your Image on the Stealer’s Site

Adding code to your .htaccess file is the best method as far as I’m concerned as you can add custom functionality through the code. You can display a custom image like the following embarrassing image when your bandwidth is stolen.
You can display any custom image like the above one, when someone steals your Bandwidth. For that to happen, all you need to do is replace the URL in the code below with the URL of the image you want to display and add this piece of code into your.htaccess file in place of the last line already given in the code above.

RewriteRule \.(jpg|jpeg|png|gif)$ http://hpmouse.googlepages.com/hotlink.gif [NC,R,L]
#Hotlinking Protection [theCollegeStash.com]

Please keep note that any small error in the .htaccess file could lead to your site crashing in a few moments, which ofcourse will need your immediate attention. If you have any queries regarding this topic then please feel free to reach me through the comments section below.