This forum has been moved here:
Helicon Tech Community Forum

ISAPI_Rewrite 3.0 (Forum Locked Forum Locked)
 Helicon Tech : ISAPI_Rewrite 3.0
Subject Topic: Hot Linking Block
Author
Message |
wlpdrpat
Groupie


Joined: 19 December 2008
Location: United States
Posts: 45
Posted: 03 January 2012 at 7:33am

Hey Anton,

I have over 100 sites on my server and many of them share images.

However, I've noticed that our images are showing up on other sites
that are not on our server and I would like to block them.

I tried the following:
RewriteCond %{HTTP:Host}#%{HTTP:Referer} ^([^#]+)#(?!http://\1).+
RewriteRule .*\.(?:gif|jpg|png) /block.gif [NC]

This achieves the desired result of blocking image on sites that are not
on my server but the unexpected/undesired result is that it also blocks
all images that are shared from one site to anther on my server.

Is there a way that I can customize this so that it will allow the sharing
of images between sites on my server but block sites that are not on my server
from using the images?

Thanks,

Pat



Edited by wlpdrpat - 03 January 2012 at 1:22pm
Back to Top Visit wlpdrpat's Homepage
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 04 January 2012 at 10:10am

Hello, Pat

Please try to have the following config for that. Replace yoursite1, yoursite2, etc with the site names on your server.

RewriteCond %{HTTP:Referer} (?:www.yoursite1.com|www.yoursite2.com|etc)
RewriteRule .*\.(?:gif|jpg|png) - [NC,S=1]

RewriteCond %{HTTP:Host}#%{HTTP:Referer} ^([^#]+)#(?!http://\1).+
RewriteRule .*\.(?:gif|jpg|png) /block.gif [NC]

__________________
Regards,
Anton
Back to Top
 
wlpdrpat
Groupie


Joined: 19 December 2008
Location: United States
Posts: 45
Posted: 04 January 2012 at 3:42pm

Hey Anton,

That works perfectly! I wish their were a work around for having to list all of my sites especially with some of my domains having many sub-domains.

I tried a number of ways to adapt this so that it would work for all my hosted sites without having to list them but never got it working. So, for the moment I am using it on one multi-portal site that has a dozen domains rather then using it server wide.

If you have any ideas on how it could be used server wide for all my hosted sites and then being able to add a few non-hosted sites, e.g. facebook.com. That would be amazing!

Thanks,
Pat
Back to Top Visit wlpdrpat's Homepage
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 05 January 2012 at 3:08am

Hello, Pat

you can have a mapfile near the .htaccess with the list of all sites, e.g.

mapfile.txt:
www.yoursite1.com www.yoursite1.com
www.yoursite2.com www.yoursite2.com
facebook.com facebook.com

And then use the following config;

RewriteMap mapfile txt:mapfile.txt [NC]

RewriteCond %{HTTP:Referer} http\://([^/]+)
RewriteCond ${mapfile:%1|NOT_FOUND} !NOT_FOUND
RewriteRule .*\.(?:gif|jpg|png) - [NC,S=1]

RewriteCond %{HTTP:Host}#%{HTTP:Referer} ^([^#]+)#(?!http://\1).+
RewriteRule .*\.(?:gif|jpg|png) /block.gif [NC]


__________________
Regards,
Anton
Back to Top
 

Sorry, you can NOT post a reply.
This forum has been locked by a forum administrator.

Printable version Printable version