Url.rewrite on lighttpd


I allow the users of my application to upload images on the server,
that are supposed to be used for some custom web pages.
However some evil ones decided that this feature gives them some storage
space that they could use for outside pages.

I would like to configure lighttpd.conf so that when images from certain
directories are accessed with a different referrer, I would pass a
banner of
my site instead.
Does anyone have a working example of something similar?
My attempts have failed, with lighttpd simply ignoring my rewrites.