How to prevent others steal your web image (hotlinking)

My website’s images are kept 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 directly links to my website image


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


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} !^https?://(.+\.)?yourwebsitehere\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /image/nohotlink.jpe [L]
# END prevent hotlinking image

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

4. Test

The image is replaced with your custom image ~


Alternative solution

The alternative solution is watermark your image, but it still eats up your bandwidth.


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 on your server? It’s quite easy also 🙂 ~

author image


Founder of, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities. Read all published posts by


newest oldest most voted

Probably that poor guy never knew he was eating your bandwidth 😛

Vinod Kumar Kashyap
Vinod Kumar Kashyap

Great Tip!!! Thumbs Up 🙂

Rados?aw Osi?ski
Rados?aw Osi?ski

Wow! Thank you for this tip.