homepage Welcome to WebmasterWorld Guest from 54.242.241.20
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / WebmasterWorld / New To Web Development
Forum Library, Charter, Moderators: brotherhood of lan & mack

New To Web Development Forum

    
Anti-image leeching with .htaccess
Scooter24

10+ Year Member



 
Msg#: 151 posted 12:01 pm on Oct 29, 2002 (gmt 0)

My site is a huge photogallery and I just opened a new domain (mydomain2) where I plan to simply keep JPG images. I'll use this second site as a source of bandwidth. When you call an HTML page of the first site the corresponding JPG is loaded from the second site.

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?

 

JamesR

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 151 posted 11:18 pm on Nov 7, 2002 (gmt 0)

Bumping this thread for you scooter. Don't have the answer myself...anyone?

jdMorgan

WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 151 posted 11:37 pm on Nov 7, 2002 (gmt 0)

Scooter24,

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / WebmasterWorld / New To Web Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved