lighttpd forum migration > Prevent hotlinking to a certain directory

Posted by Christian (Guest)
on 18.12.2007 22:35
Hi!

I have a mod_rewrite problem I am trying to solve on lighty before I can 
migrate from apache. I am using lighttpd 1.4.18

The "RewriteCond %{HTTP_REFERER} !^$" is important, aka the user can 
link directly in his browser because this prevents that personal 
firewall/proxies get a hit on the rule.

So I want that only certain referer domains and "no referer" should have 
access to the image files under the directory /images/ and its 
subdirectories.

Can this be solved?

--- code that I have in my apache config ------
<Directory "/home/sitedir/www/www.domain.com/image">
 RewriteEngine On
 RewriteBase /
 RewriteCond %{HTTP_REFERER} !^$
 RewriteCond %{HTTP_REFERER} !^http://domain.com/.*$ [NC]
 RewriteCond %{HTTP_REFERER} !^http://www.domain.com/.*$ [NC]
 RewriteCond %{HTTP_REFERER} !^http://srv4.domain.com/.*$ [NC]
 RewriteCond %{HTTP_REFERER} !^http://srv5.domain.com/.*$ [NC]
 RewriteRule .*\.(gif|GIF|jpg|JPG|jpeg|JPEG|png|PNG)$ 
http://www.domain.com/hotlink.gif [NC,L]
</Directory>
--- end code ------