Htaccess and redirects



I’m trying to restrict access to images in a certain directory. I’m able to do this with .htaccess, like so:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$ [NC]
RewriteRule .
.(gif|jpg|jpeg|bmp|JPG)$ [R,NC]

So right now, anytime anyone tries to view an image with the listed extenstions, they are redirected to test.html.

Is there an easy way to use htaccess to redirect them to a php file, that takes the image name as a parameter? I have a php script that will verify that a user is a paying visitor before displaying an image, and having htaccess forward to that page would be very useful.