How to Prevent Image Hotlinking from Specific Domains

Image hotlinking is nothing new, and content scrapper find a new way to copy blog posts from your blog. It could be simple using your RSS feed to create a duplicate copy of your blog posts, or using any software or WordPress plugin, to copy your blog posts and republish it. We have DMCA to handle such copy-paste blogger, but how about image hotlinking?

How to Prevent Image Hotlinking

Those who are on unlimited bandwidth hosting like Bluehost or Hostgator, they won’t feel any problem with others stealing their images, but it affect your Website performance, and also steal your bandwidth. More over, they are getting free credits for your work. There are plugins like Watermark reloaded, which adds watermark to your images to take care of branding, but this doesn’t solve our problem of bandwidth theft. One way to stop image hotlinking by showing custom image or forbidden message, when someone hotlink your images.

What is Image hotlinking?

For newcomers, hotlinking is the process of copying someone image, and using their bandwidth. For example, if you will copy this entire post, you will also be copying image, but image is still hosted on my server. So, when ever someone will open, copied blog post on your website, technically it’s consuming my server bandwidth to serve that image. Needless to mention, it not only increases server cost, but also increases load on my server. Specially, is someone hotlinked to your old image, and you deleted it, you will find many error messages in your server log file.

There are many ways to prevent image hotlinking, which start from using your hosting panel or using a simple WordPress plugin. Though, major problem which I found using cPanel method to stop image hotlinking is, it prevent showing images to your feedburner users, and many other websites. This is indeed a headache for your regular readers.

Using .htaccess method to prevent image hotlinking [WordPress]

Today, I was working for a client, who is facing issues with 2-3 specific websites, who are leeching her server bandwidth. My goal was to prevent image hotlinking from specific domains. You can always stop image hotlinking from every other domain apart from yours, but a good idea would be to ban specific domains.

Here I’m sharing .htaccess code which I used to stop those image bandwidth stealing domains, and you can use it on your blog. Few things which you should know before using this .htaccess code. Here are two guides, which will give you basis of WordPress .htaccess file:

Login to your FTP, and at the root folder, you will find .htaccess file. Make sure, your FTP client is configured to show hidden files. Now, open .htaccess file and at the top, add given .htaccess code:

Image hotlinking

RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?badsite\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?badsite2\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?blogspot\.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?livejournal\.com/ [NC]
RewriteRule .*\.(jpe?g|gif|bmp|png)$ [L]

Few things to know before you use above .htaccess code to stop image hot linking:

  • badsite = name of the site, which is copying images from your blog.
  • – This will prevent image hotlinking from all BlogSpot sub domains.
  • Image URL: In the last line, you can replace imageshack image URL, with any other image you want. Use something provoking, that will make webmaster to stop hotlinking images from your domain.

Here is the screenshot of my .htaccess file, which I used to prevent image hotlinking:

Prevent image hotlinking

You can download this .htaccess code from this file. Make sure you replace the domain names, with one you want to block. Also, if you are testing this .htaccess code, make sure to delete your browser and server cache.

I hope this would help people who are facing issues with websites stealing their bandwidth, and taking credit of your image work. If you still have any query, feel free to ask via comments. You can join ShoutMeLoud on Facebook, for more updates.

Subscribe on Youtube

Article By
Harsh Agrawal is a blog scientist and a passionate blogger. He is blogging since 2008 & writes about Blogging, SEO, Make money online & tech. His blog, ShoutMeLoud receives 1 million Pageviews/month and have over 700K subscribers.


COMMENTs ( 8 )

  1. Kushal Azza says

    Hi Harsh,
    Thanks for information.

    Does it effect Google Image Search? I was some images on Google, on-click, it will show some default images but not the original.

  2. ashish says

    hi harsh sir,

    Great post about image hotlinking. I use a watermark on the images which are used in post. But is it OK to host big Images on other server, You know i use Dropbox somoetime to host my images.

  3. says

    Thank you Harsh, this is very helpful. I’m planning to build an image-extensive site in the future so this info and that htaccess file helps a lot.

  4. Nizam Khan says

    Excellent and much useful post. Didn’t know about image hotlinking. This post does helped a lot to learn about it and well described on how to stop image hotlinking using .htaccess . Thanks a lot Harsh :)

  5. desi Traveler says

    Hi Harsh….Great post, but please pardon my ignorance… how to find if somebody is using my images.
    As a travel blogger I post a lot of images, but now a days I post them on my Facebook or Flickr account and hotlink them to wordpress. This way I don’t have to upload the images again. Do you think this is a good practice or I should revert back to uploading the images to wordpress itself. Thanks

  6. says

    Hi Harsh… great post, but please pardon my ignorance.. how do I find out if some body is using my images? As a travel blogger I post a lot of images. Though now a days I hotlink my own images from my Facebook or Flickr account. This way I don’t have to upload them again on wordpress.

    • says

      There are many ways to find, if somebody is using your image or not. If you are hosting images on your server, your server logs can show that.
      You can also take advantage of reverse image search, to find the copy of your copyright images.

      Regarding hotlinking your own images by hosting them on FB or Flickr: It’s a bad idea for many reasons:

    • You lose the benefits of Image SEO
      Your image will start showing 404 error after some time
    • If bandwidth is an issue, you could always go with unlimited Webhosting companies, or use a CDN which is faster and cheaper…