Not how I intended to start the weekend, but still . . .

I was supposed to be at the Yarn Barn by now.


As Kelly is fond of pointing out, sometimes I just get focused on some weird-ass thing and cannot let it go. If only I could apply this in a deliberate fashion, I’d be in charge of a small country by now.

A while ago, one of my pals sent me a somewhat alarmed e-mail after her hosting provider sent her an abnormally large bill for her site’s bandwidth usage. After poking around a little bit, we both agreed that one possible suspect was external sites hotlinking to her images. That is to say, someone else put a URL on their website that linked directly to an image on hers. While this might seem like an innocent enough thing to do, it’s terribly rude.

Why? Because when you do that, you are wasting the original site’s bandwidth. Most of us have to pay for data transfered from our web sites if it goes over a certain amount each month. So if you’ve got a just unbelievably cute OMGLOLWTF picture of a little fuzzy kitty (for instance) on your blog, and a dozen mouth-breathing keyboard-drooling MySpace tweakers decide to put a link directly to that picture, then every time those MySpace pages get viewed, your webserver is going to get the request for the picture and send it to the browser that’s requesting it. This means your servers’ bandwidth is being used without your site getting the benefit of being viewed in its entirety.

Not cool. The decent thing to do in this situation is download the picture and upload it to your own site. Or, if you’re a really well-adjusted member of society, you might actually ASK if it’s okay to use the picture in the first place.

So what does this have to do with why I’m still sitting in front of the computer in my skivvies and not at the Yarn Barn yet? Well, when this episode originally unfolded, I set up some rules for my friend’s webserver to use which would automatically deny any request for an image that came from another website. The rules were implemented using something called a RewriteRule which the Apache webserver supports. And after setting it up on her site and testing that it worked, I decided to add it to mine too. My blog doesn’t get nearly the traffic hers does, but I do have an awful lot of images on my site and I’d just as soon not have too much bandwidth wasted by people who aren’t coming here to read my entries.

Well, I’d noticed lately that the amount of bandwidth that was being used to serve images was staying pretty consistently high. For a while I just figured that this was because I have images in almost every post (not to mention the site graphics), and images are a lot bigger than text is. But this morning I went through my log files on my server and noticed that there were a LOT of MySpace referers that were getting single images. That is to say, there are MySpace pages (and others) that are hotlinking to my images but not my posts.


Okay, so I opened up the Apache configuration files on my server and found the Rewrite section. Everything was turned on and active. I went to one of the sites that was hotlinking to me and sure enough, there was a famous picture of Morgan in the middle of the page. Grrr.

At this point, since your eyes are probably already half-glazed over, I’m going to skip ahead to where I started reading the Rewrite Engine documentation and found that Rewrite rule don’t get inherited by virtual hosts. See, my server hosts a couple of websites, SweaterProject being just one. Since I wanted to give all my users the same protection against hotlinking, I put the Rewrite rules in the general section of the Apache configuration file. But it turns out that does not work. So I moved the rules into the section that defined the rules just for SweaterProject, and lo and behold – no more hotlinks.

And it only took an hour and a half. I could be done with Zach’s baby’s hat by now. (Of which there will be photos later this weekend here, and only here, on SweaterProject.)

No Responses to “Not how I intended to start the weekend, but still . . .”

  1. cari Says:

    It was totally Myspace folks eating up my bandwith too. Fuckers.

  2. janna Says:

    But now there are no graphics at all — the banner is missing entirely, and the others are broken…..

  3. David Says:

    And Grrr again.

    Would you like a side of Grrrr with that?

    I can apparently turn off images for EVERY site, including my own, but I can’t get it to selectively refuse images to other sites. This is really pissing me off.

    Oh well – better things to do today. I’ll take another crack at it tomorrow night.

  4. bonnie Says:

    What’s funny to me as that as a non-geek, I’m still sitting here reading this post. Half of this makes no frickin’ sense to me whatsoever LOL. I kept reading anyhow though to see if I could figure out if I was one of the bandwith burglars (with the throwies). But I’m not. Neener neener.