Main Content

Finding and diverting image requests from rogue domains

Archive - Originally posted on "The Horse's Mouth" - 2011-03-08 08:15:40 - Graham Ellis

Search engines search images as well as text these days - and our images are often picked up because we're "good boys" and label them with alt attributes. Good - that helps generate traffic. However, there are some image search engines which have a tendency to be used for, and to feed out, adult material, which they dilute with other images, and we don't really want those images to be ours, especially pictures that include family members!

We track image use ... see [here] for pictures hotlinked from our site in the last day or so ... and when I'm logged in to our server, I can see the URL that was used as well. We don't add the links on the public page as that would only encourage the providers of these sites!

It's one think finding out about these image uses - but that's only half the story. Can we prevent then being used in this way? Not totally, but we can look at the requests made for the images and use Apache's mod_rewrite to divert the requests to a different image. Here's the code that I've added to the appropriate .htaccess file to switch images within a directory for all particular uses from the pages of one of the domains that we needed to control:

  RewriteEngine on
  RewriteCond %{HTTP_REFERER} dearcomputer [NC]
  RewriteRule \.jpg http://www.wellho.net/pix/tramm3.jpg [R]


The image that illustrates this article is the one that will be displayed on the sites that we have controlled.