Log in

No account? Create an account

Previous Entry | Next Entry


I don't look at my web page statistics very often. I get enough monthly hits that I don't have to feel neurotic about it.


I found quite a few instances where folks were leeching images (the "Stewie" portrait thumbnail is very popular) for web forum user icons and .sig lines. Now I'm not going to search for folks who have swiped a copy and host it on their own servers (it's not like i've got permission to use the image in the first place), but I've got no interest in offering up my bandwidth to someone who is going to use the image for something other than linking to my site.

Fortunately for selfish bastards like me, there's this thing called mod_rewrite and a lot of nice tutorials and hints on how to make it work for you.

This is the ruleset I like...
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?bovil\.com [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?irlm\.org [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?twistedimage\.com [NC]
RewriteCond %{HTTP_REFERER} !^http://(.+)?livejournal\.com [NC]
RewriteCond %{HTTP_REFERER} !.*search\?q\=cache.* [NC]
RewriteCond %{HTTP_REFERER} !.*search/cache\?.* [NC]
RewriteRule .*\.(gif|jpg)$ - [F,L]

What does this do? It's designed to exit if any condition is matched, and fail the image load if none do.
  • The first condition bails when there is no referrer. This is important, some browsers and firewalls supress referrer information, and you don't want to block them.

  • The following three bail when the referring URL matches preferred domains that I'm willing to let link images in. It's important to remember to include your site as one that's allowed to link images.

  • The "livejournal" condition bails on any LJ url. I host images for my journal on my webserver

  • The "cache" conditions bail when an image-search cache page loads the image.

  • The last line (rule) returns a failure code for gif and jpg images if no condition has been matched.


( 2 comments — Leave a comment )
Oct. 20th, 2004 06:43 pm (UTC)
ja, htaccess can be your friend.
it can also protect any other file types you care to add between pipes. this is useful for zips of things that you want 5 or 10 people you know to have access too, but you don't want Russian hotlinkers featuring your stuff on their site.
the last line also allows an interesting addition - you can specify an alternate image to load, so "hotlinkers suck" or a webcam image of your finest finger is possible. one advantage to even using a single pixel gif for this purpose is that if your web hosting keeps access logs you can grab the massive text file at the end of the month and casually "find" for the image file name. you can then see if you've actually been hotlinked or have just become popular in your own forums by counting the appearances of "hotlinkers.gif" or what-have-ye.
i'm a particularly stupid monkey, but it works for me. whee!
Oct. 20th, 2004 11:33 pm (UTC)
The sample I was working from included a bunch of other filetypes, but I trimmed it back when debugging (there were a few botched regexes in it).

I'm running Analog and ReportMagic daily to analyze my logs, so I can check for odd referrers and strange usage easily. The only thing I've got that I'm worried about folks leaching is the .jpg and .gif files; my .pdf files all have my name all over them and I don't leave other filetypes up for more than a day or two.
( 2 comments — Leave a comment )

Latest Month

February 2014

Page Summary

Powered by LiveJournal.com
Designed by Paulina Bozek