My website’s images are keep directly link (hotlinking) by other websites, it’s a thief behavior and eating my bandwidth, why don’t they copy to their own server and display it? I decided to take action to stop this happened again, this so called “hotlinking” can be stopped by “.htaccess” access control.

Case Study

1. Hotlinking my image

This website is directly link to my website image

steal-nohotlink

2. Design custom image

Create a custom image with paint, save it as “nohotlink.jpe“. This image file will use as your linked image replacement. Just put some text like “do not steal my bandwidth”, and upload to your server image folder.

This is my custom image

nohotlink

3. “.htaccess”

Place a file called .htaccess in your hosting’s Apache root directory. e.g /public_html/.htcaccess

Put this text into your .htaccess file.

# BEGIN prevent hotlinking image
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?yourwebsitehere\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /image/nohotlink.jpe [L]
</IfModule>
# END prevent hotlinking image

Replace the text “yourwebsitehere” with your website name. More explanation here

4. Test

The image is replace with your custom image ~

steal-nohotlink-1

Alternative solution

The alternative solution is watermark your image, but it is steal eat up your bandwidth.

Conclusion

I just do not like this kind of direct image link behavior, please do not steal like this, why not just print screen and put the image in your server? It’s quite easy also :) ~