Hotlinking – How to stop other web sites from including images from your web site

What is hotlinking? Hotlinking is when a web site owner includes images from your web pages in their web sites. The problem is that it drives up your web site hits, transfer usage, your web hosting bill, and all most likely without them crediting your site as the source of the image.  Why did I create this how-to?  There are a couple of hotlinking tutorials out there but they are missing an important note (in bold below) and don’t include a funny image.

One of my sites was suffering from thousands of hotlink image hits per day so I did the following to correct the problem.

Update your .htaccess file and include the following :

# This code is used to surprise hotlinkers
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(.*\.)?your-web-site.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(.*\.)?google.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(.*\.)?facebook.com [NC]
RewriteRule .*\.(jpe?g|gif|bmp|png)$ http://img853.imageshack.us/img853/7006/internetthief.jpg [NC,R,L]

You can choose to redirect the thieves to any image. You must host the redirect image on a different domain from your web site! I found the picture above and added the wording about stealing web server resources. Feel free to use it too. Also, the code above allows Google and Facebook to use your images.  It is also a good idea to add your other web sites to the allow list so that you dn’t have a problem linking images between your own web sites.

Tags: , , , , , , , , ,

Leave a Comment