myspace is not my space, which isn’t your space
I was browsing through my weblogs over the weekend, and discovered that my bandwidth use is waaaaaaaaaay up. Most of it comes from a clip of the Drew Carey show where Richard Simmons plays the part of various props. It’s one of those clips that brings tears to your eyes, so I’ll share for a little while longer, then change the URL in a day or so.
The other area that it comes from is people who use myspace and a few forums hotlinking to images as part of their sig. I have no problems with folks downloading and hosting them elsewhere (and with all the free image hosting services, there’s no reason why they can’t), but don’t use my fircking bandwidth. It’s a common problem, unfortunately.
Thankfully, apache’s rewrite rules makes dealing with the large majority of the requests originating from myspace pretty straightforward. If the browser sends a referrer (very few don’t, although programs like Norton Internet Security block them by default) from a myspace hostname, they’ll get a different image than what their browser requested.
Some folks use an image that is somewhat distasteful to punish hotlinkers, but I figure a simple message is more effective, and the image they get is only 900-odd bytes. (plus the image itself makes them look funny in their forums, because their sig is supposed to be an expression about them). Once they clue in, they usually change things pdq.
A little thing to be true, but I feel better about it.
The rewrite rule, in case you were wondering, is a whole two lines:
RewriteCond %{HTTP_REFERER} ^http://([^/]+)myspace\.com/.*$ [NC]
RewriteRule \.(jpe?g|gif|bmp|png)$ /images/leech.gif [L]
Update: If you’re hosting your site on Apache using a provider, you can usually add rewrite rules using .htaccess files. JavaScript Kit provides a well-written overview on .htaccess, which includes a section on blocking access by referrers. Have a look-see, as it’s a great starting point for understanding how this stuff works, and what you can do to control how Apache handles page requests with your site.