How do I redirect images?
December 15, 2005 11:23 AM   Subscribe

How can I redirect images to stop bandwidth leeching?

On my band's website, we've recently been the victim of a very large amount of bandwidth leeching. That is to say, we have been having a large number of people link to images that are stored on our server and use them on their page. We wanted to create a redirect image (nothing like tubgirl, just something tame), so that instead of stealing our imagery, they have a "Official Look Machine Fan Club Member" image that we've created. (And then, they will quickly leech from someone else's server probably and leave ours alone). I know this is possible, but how do I do it? Also, we're on dreamhost and we host a number of sites on the same server, if that makes a difference. We only want to redirect images that are on different domains.
posted by jasonlatshaw to Computers & Internet (16 answers total) 1 user marked this as a favorite
See here
posted by sanko at 11:26 AM on December 15, 2005

Use 301 re-directs.
posted by SweetJesus at 11:26 AM on December 15, 2005

Response by poster: I think in reference to the first one, I'm not sure that's what I want to do. I don't want to just prevent others from using our images (although I guess that's a plan B), ideally, if possible, we want everyone who is stealing an image to instead display a particular image that we could upload to our site.
posted by jasonlatshaw at 11:31 AM on December 15, 2005

I hate to do this, but honestly, your best place to start is Goooogle unless you have specific questions on this well-covered topic.
posted by kcm at 11:35 AM on December 15, 2005

Best answer: Put an .htaccess file in your images directory:

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yoursite\.com [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule \.(jpeg|jpg|gif|bmp|png)$ /otherdirectory/hotlink.jpg [L]

Where "hotlink.jpg" is your little "Fan Club Member" image.
posted by Gator at 11:39 AM on December 15, 2005

Not the solution you're looking for but when that happened to me I didn't get mad, I got even.
posted by Taken Outtacontext at 11:56 AM on December 15, 2005

Taken Outtacontext: So did I.

I love that someone would actually hotlink an MP3. Classy, that.

Images are somewhat expected. Especially with this whole MySpace generation: Everyone's little home on the web lacks sufficient storage, and why would some 14 year old bother copying an image to his own server/server space when he can just tweak IMG SRC.

The reality here is that I highly doubt most people understand what's happening. A lot of people learned simply by example. They saw some friend had an image, discovered you could "View Source" and figured out how th tweak IMG SRC tags appropriately. It doesn't mean that they understand what's happening underneath, or why someone might get upset.

Fortunately, we have recourse from such things, as Gator, et al describe above.
posted by disillusioned at 12:59 PM on December 15, 2005

Myspace caused this problem for me. We do CD reviews and so we come up first in a lot of google images searches and myspace links the living hell out of us.

I created an alternative image that comes up using the .htaccess technique posted above:

Here's what they get. :-)
posted by twiggy at 1:15 PM on December 15, 2005

For what it's worth, teaching them a lesson can be a good thing; just because 14 yo do it..doesn't mean it's okay.

For that reason I link to the history of linking to a shock site. The link it totally safe - it just links to a wikipedia article about shock sites.

Search for Something (as in Something Awful) - and read (do not click on any image link to see what they did. Essentially they made it so anyone who leeches get a horrible, horrible picture (rather than the happy unicorns they linked to)
posted by filmgeek at 1:56 PM on December 15, 2005

Response by poster: I really wouldn't post a question without googling. The solutions I found through googling weren't working quite right, mostly because of sharing domains on the same server (technically, they are virtual domains).

I'll try these solutions, thanks everyone!
posted by jasonlatshaw at 2:09 PM on December 15, 2005

Some livejournal asshole was hotlinking to a large drawing of mine, using it as the background for his site (tiled too.. it was awful). So, I replaced the file he was hotlinking with a 1x1 pixel that was the same color as his text, so that the entire page was pretty much unreadable until he changed it.
posted by Hildago at 3:41 PM on December 15, 2005

Gator what would the code look like if I wanted to allow vistors of a few sites (say metafilter,, and to see images hosted on my server but not anywhere else? And does that code have to be in the same directory as my images or just somewhere along the path. IE: could I put that code at the root of my image folder and have images in sub folders protected from leaching?
posted by Mitheral at 3:53 PM on December 15, 2005

Response by poster: Hey all --

Thanks loads everyone, we got it up and running and it's perfect.

Check out, for example. . . this.

I love it, now there are literally thousands of people on the web professing their look machine fan club membership. . . hilarious.
posted by jasonlatshaw at 5:25 PM on December 15, 2005

Best answer: My preferred replacement image is a PNG that is one pixel wide...and 16383 pixels tall. It's hell on layouts.
posted by oaf at 5:39 PM on December 15, 2005

The last image on jasonlatshaw leacher's page is hilarious in context, it's got a big ol' copyright symbol all over it.
posted by Mitheral at 6:04 PM on December 15, 2005

Mitheral, to allow certain sites to hotlink your images, just add extra lines to the .htaccess file specifying those sites:

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yoursite\.com [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?metafilter\.com [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?ebay\.ca [NC]

RewriteCond %{HTTP_REFERER} !^$
RewriteRule \.(jpeg|jpg|gif|bmp|png)$ /otherdirectory/hotlink.jpg [L]

The .htaccess file has to be in the same directory where your images are stored; however, it's very important that your replacement image ("hotlink.jpg") has to be in a different directory ("otherdirectory" in my example), outside your images folder -- NOT a subdirectory of your images folder. Yes, if you put this .htaccess file in your images folder, it'll protect images in any subdirectories of that folder.

There are other ways to do all this, of course. Googling for htaccess hotlink image replace or similar terms will bring up all sorts of resources.
posted by Gator at 6:47 PM on December 15, 2005

« Older Better sound device management on OSX?   |   What is the legal status of software developed... Newer »
This thread is closed to new comments.