Sorry for my English. I used it for. Htaccess, but it is half-baked solution that takes the user to the main page. What do to when you click on "View original image" guest was moved to the side of the picture:
http://www.MYDOMAIN.com/details.php?image_id =
RewriteCond %{HTTP_REFERER} !^http://www.MYDOMAIN.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.MYDOMAIN.com$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$
http://www.MYDOMAIN.com/ [R,NC]
I would be grateful for any hint.