What to do about Image Leeching

Leeched Image vs Normal Image

Every now and then somebody builds a web site with the brilliant idea that they will uses images from other peoples' web sites as part of their content. They enjoy the benefits of the traffic (for example, advertising revenue), while the image owner ends up paying for the bandwidth. This is called image leeching.

What can you, as a web site owner, do about this?

If you're running a good web server, e.g. Apache, then you can block all requests to images from browsers which specify a referring site other than your own. In your .htaccess file, you can add a rewrite rule something like this:

  RewriteCond %{HTTP_REFERER} !^$                                  
  RewriteCond %{HTTP_REFERER} !^https?://www.example.com/.*$ [NC]
  RewriteRule .*\.gif$        -                            [F]

This forces all requests for .gif files to fail ([F]) if the page in which the image is embedded (given to us as the Referer: (sic) in the HTTP request) is neither blank nor matches www.example.com. Refer to the Apache URL Rewriting Guide for more details.

But where's the fun in that?

Blocking traffic is really no fun at all. Instead, why not enjoy yourself at the other web site's expense?

For example, at once time you could have clicked on an icon which included the word sex on a now defunct website called iconsurf.com that linked to our website.

We looked at where you were coming from in our .htaccess file, and if you were coming from iconsurf.com gave you a more interesting icon:

  # Give iconsurf.com visitors something interesting to look at
  # Note: due to a bug they often ask for //favicon.ico instead of /favicon.ico
  RewriteBase /
  RewriteCond %{HTTP_REFERER} iconsurf [NC]
  RewriteRule favicon\.ico$ image_leeching.ico [L]

Then, when you arrived, we re-directed you to this page:

 # Note the checks for the rewritten URI to prevent looping
 RewriteCond %{HTTP_REFERER} iconsurf [NC]
 RewriteCond %{REQUEST_URI} !^/image_leeching.ico$
 RewriteCond %{REQUEST_URI} !/resources/image_leeching
 RewriteRule !favicon\.ico$ https://www.albionresearch.com/resources/image_leeching [R,L]

With this combination of techniques, you can display what you like on the other site's page and, if they link to you, redirect any inbound traffic to the page of your choice.

O tempora, o mores!*

In 2021 we had to change the name and wording of this page: search engines had become more prudish, and our old title apparently caused this page to have a not-safe-for-work classification.

Tools for Webmasters and Others

© 1993-2024 Albion Research Ltd.
Need Better Web Hosting?

Can we suggest you look at some of the companies we use?

Virtual private servers from only $5/month. Good for serious web apps as well as simple sites. You can also rent a server for cents an hour to test your ideas.

Note: the above are affiliate links to companies we use. Signing up using these links helps pay for the cost of this page.