Forum Moderators: mack
I'd like to prevent image leeching and only allow GET requests for JPG images of the second site if the referrer is from the first site (or if it's Google). I might use the following rule:
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?mydomain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www\.google\..*$ [NC]
RewriteRule \.(jpg¦JPG)$ [mydomain.com...] [R,L]
But how do I prevent somebody from viewing an image by directly entering a URL like this:
[mydomain2.com...]
In other words I'd like to allow GET requests for JPG images from the second domain only if they come from the first domain - not if they are direct requests (and of course not if they are from another domain). How to do this?
Well, with .htaccess, you really can't... Your first RewriteCond is needed to allow your site to be viewed through proxy caches. If you take it out, then anyone without a referer won't be able to view your site. Many proxy caches block referers... And that looks the same as a directly-entered URL. :(
Also, remember that "anything.*$ [NC OR] is the same as "anything [NC,OR]" - just leave off the end anchor.
Jim