Lighttpd image hotlinking prevention

I’ve migrated our image server from apache to lighttpd, it certainly feels a bit faster, but preventing hotlinking is not as easy as with apache.

The standard documentation only tells you how to deny access to images when hotlinked, but I want people to know that they’re hotlinking images. So I needed any hotlinked image to be responded with a “don’t hotlink”-image.

It was a bit of struggle trying to find the right syntax, but I finally succeeded. This is doing it’s work great


$HTTP["referer"] !~ “^($|http://(.*)?kmfstudio|afspot\.com)” {
$HTTP["referer"] !~ “^($|http://(.*)?asianfanatics|afspot|hkadb|afmag\.net)” {
url.redirect = (
“(/.*\.(JPG|jpe?g|png|gif))$” => “http://kmfstudio.com/hotlinking/hotlinking.jpg”
)
}
}

1 Comment »

  1. niyas hussain said,

    January 27, 2008 @ 6:35 am

    where should I put this code. :)

RSS feed for comments on this post · TrackBack URI

Leave a Comment