Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
ISAPI_Rewrite 2.x support forum
 Helicon Tech : ISAPI_Rewrite 2.x support forum
Subject Topic: hotlinking and google images Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
papachumba
Newbie
Newbie


Joined: 27 January 2006
Location: United Kingdom
Online Status: Offline
Posts: 18
Posted: 27 January 2006 at 8:48am | IP Logged Quote papachumba

Hi, we purchased your isapi mod rewrite module today.
I have sucessfully installed this onto our corporate webserver.

Using the following script the hotlinking is disabled but there are a few problems:

# Block image hotlinking
RewriteCond Host: (.+)
RewriteCond Referer: (?!http://\1.*).*
RewriteRule .*\.(?:gif|jpg|png) /block.gif [I,O]

The said webserver has multiple domains on it, and sometimes there are images being linked from one domain to the other on the same server. We would like to allow hotlinking to happen in this instance (there are around 30 domains on the server, with images occasionally being shared)
I have also noticed a problem on a secure side of the server, for some reason when the script above is utilised the encrypted page (https) would not show imagery, even though the images are sitting within the same secured folder, im sure https maybe should be added to script but i have no idea how to do it.

finally, is there any way to block google image search by using this module? We get a lot of visitors from google image searches and as these are not valuable to us and just wasting bandwidth i was wandering if it is possible to block google from showing the images directly.

Back to Top View papachumba's Profile Search for other posts by papachumba
 
Lexey
Moderator Group
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Online Status: Offline
Posts: 7468
Posted: 27 January 2006 at 4:00pm | IP Logged Quote Lexey

>The said webserver has multiple domains on it, and sometimes there are images being linked from one domain to the other on the same server. We would like to allow hotlinking to happen in this instance (there are around 30 domains on the server, with images occasionally being shared).
 
You will have to list all domains in the 2nd RewriteCond in this case. Rule could be like:
 
RewriteCond Referer: (?!http://(?:www\.domain1\.com|www\.domain2\.com)).*
RewriteRule .*\.(?:gif|jpg|png) /block.gif [I,O]
 
>I have also noticed a problem on a secure side of the server, for some reason when the script above is utilised the encrypted page (https) would not show imagery, even though the images are sitting within the same secured folder, im sure https maybe should be added to script but i have no idea how to do it.
 
That is because Referer check explicitly checks for http. Corrected rule will be:
 
RewriteCond Referer: (?!https?://(?:www\.domain1\.com|www\.domain2\.com)).*
RewriteRule .*\.(?:gif|jpg|png) /block.gif [I,O]
 
Also, I would recommend to allow empty Referers. Corresponding rule will be:
 
RewriteCond Referer: (?!https?://(?:www\.domain1\.com|www\.domain2\.com)).+
RewriteRule .*\.(?:gif|jpg|png) /block.gif [I,O]
 
>finally, is there any way to block google image search by using this module?
 
I guess, you could block them by User-Agent. It will be something like (you will need to put real Google UA there):
 
RewriteCond User-Agent: GoogleSearcher
RewriteRule .*\.(?:gif|jpg|png) /block.gif [I,O]
 


__________________
With best wishes,
Alex Ostapenko,
Helicon Tech.
Back to Top View Lexey's Profile Search for other posts by Lexey
 
papachumba
Newbie
Newbie


Joined: 27 January 2006
Location: United Kingdom
Online Status: Offline
Posts: 18
Posted: 30 January 2006 at 9:00am | IP Logged Quote papachumba

hiya,

so i can start with something like condition below? note that we own both .com and .co.uk for these domains. Is https (one domain under https) in referer enough for normal http domains or should i include both https and http on 2 separate lines?

and another question, is block.gif a file that gets displayed if the rule is enforced?

# Block image hotlinking
RewriteCond Host: (.+)
RewriteCond Referer: (?!https?://(?:www\.mydomain\.com|www\.mydomain\.co.uk)).+
RewriteRule .*\.(?:gif|jpg|png) /block.gif [I,O]



Quote: Originally posted by Lexey on 27 January 2006
>The said webserver has multiple domains on it, and sometimes there are images being linked from one domain to the other on the same server. We would like to allow hotlinking to happen in this instance (there are around 30 domains on the server, with images occasionally being shared).
You will have to list all domains in the 2nd RewriteCond in this case. Rule could be like:
RewriteCond Referer: (?!http://(?:www\.domain1\.com|www\.domain2\.com)).*
RewriteRule .*\.(?:gif|jpg|png) /block.gif [I,O]
>I have also noticed a problem on a secure side of the server, for some reason when the script above is utilised the encrypted page (https) would not show imagery, even though the images are sitting within the same secured folder, im sure https maybe should be added to script but i have no idea how to do it.
That is because Referer check explicitly checks for http. Corrected rule will be:
RewriteCond Referer: (?!https?://(?:www\.domain1\.com|www\.domain2\.com)).*
RewriteRule .*\.(?:gif|jpg|png) /block.gif [I,O]
Also, I would recommend to allow empty Referers. Corresponding rule will be:
RewriteCond Referer: (?!https?://(?:www\.domain1\.com|www\.domain2\.com)).+
RewriteRule .*\.(?:gif|jpg|png) /block.gif [I,O]
>finally, is there any way to block google image search by using this module?
I guess, you could block them by User-Agent. It will be something like (you will need to put real Google UA there):
RewriteCond User-Agent: GoogleSearcher
RewriteRule .*\.(?:gif|jpg|png) /block.gif [I,O]



Back to Top View papachumba's Profile Search for other posts by papachumba
 
papachumba
Newbie
Newbie


Joined: 27 January 2006
Location: United Kingdom
Online Status: Offline
Posts: 18
Posted: 30 January 2006 at 11:04am | IP Logged Quote papachumba

hi, i tried adding the rules mentioned in my previous post, but it seems that there is a problem coming into the sites from anywhere outside the server, like google for example.
It displays the blocking image on all the graphics. If i am jumping from site to site using internal links everything displays fine?
here are the rules i am using, i replaced the original domain name with "mydomain" for anonimity...

# Block image hotlinking
RewriteCond Host: (.+)
RewriteCond Referer: (?!https?://(?:www\.mydomainholidays\.com|www\.mydomainholidays\.co.uk|www\.mydomaincanada-holidays\.co.uk|www\.mydomaincanada-holidays\.com|www\.mydomainlas-vegas-holidays\.co.uk|www\.mydomainlas-vegas-holidays\.com|www\.mydomainboston-holidays\.co.uk|www\.mydomainboston-holidays\.com|www\.mydomainnew-york-holidays.co.uk\.co.uk|www\.mydomainnew-york-holidays.co.uk\.com|www\.mydomaincuba-holidays\.co.uk|www\.mydomaincuba-holidays\.com|www\.mydomainjamaica-holidays\.co.uk|www\.mydomainjamaica-holidays\.com|www\.mydomaincaribbean-holidays.co.uk\.co.uk|www\.mydomaincaribbean-holidays.co.uk\.com|www\.mydomaincitybreaks\.co.uk|www\.mydomaincitybreaks\.com|www\.mydomainitaly-holidays\.co.uk|www\.mydomainitaly-holidays\.com|www\.mydomaineastern-europe-holidays\.co.uk|www\.mydomaineastern-europe-holidays\.com|www\.mydomainegypt-holidays\.co.uk|www\.mydomainegypt-holidays\.com|www\.mydomainsouth-africa-holidays\.co.uk|www\.mydomainsouth-africa-holidays\.com|www\.mydomaindubai-holidays\.co.uk|www\.mydomaindubai-holidays\.com|www\.mydomainoman-holidays\.co.uk|www\.mydomainoman-holidays\.com|www\.mydomainmaldives-holidays\.co.uk|www\.mydomainmaldives-holidays\.com|www\.mydomainsri-lanka-holidays\.co.uk|www\.mydomainsri-lanka-holidays\.com|www\.mydomainseychelles-holidays\.co.uk|www\.mydomainseychelles-holidays\.com|www\.mydomainmauritius-holidays\.co.uk|www\.mydomainmauritius-holidays\.com|www\.mydomainhong-kong-holidays\.co.uk|www\.mydomainhong-kong-holidays\.com|www\.mydomainthailand-holidays\.co.uk|www\.mydomainthailand-holidays\.com|www\.mydomainbali-holidays\.co.uk|www\.mydomainbali-holidays\.com)).+
RewriteCond Referer: (?!http?://(?:www\.mydomainholidays\.com|www\.mydomainholidays\.co.uk|www\.mydomaincanada-holidays\.co.uk|www\.mydomaincanada-holidays\.com|www\.mydomainlas-vegas-holidays\.co.uk|www\.mydomainlas-vegas-holidays\.com|www\.mydomainboston-holidays\.co.uk|www\.mydomainboston-holidays\.com|www\.mydomainnew-york-holidays.co.uk\.co.uk|www\.mydomainnew-york-holidays.co.uk\.com|www\.mydomaincuba-holidays\.co.uk|www\.mydomaincuba-holidays\.com|www\.mydomainjamaica-holidays\.co.uk|www\.mydomainjamaica-holidays\.com|www\.mydomaincaribbean-holidays.co.uk\.co.uk|www\.mydomaincaribbean-holidays.co.uk\.com|www\.mydomaincitybreaks\.co.uk|www\.mydomaincitybreaks\.com|www\.mydomainitaly-holidays\.co.uk|www\.mydomainitaly-holidays\.com|www\.mydomaineastern-europe-holidays\.co.uk|www\.mydomaineastern-europe-holidays\.com|www\.mydomainegypt-holidays\.co.uk|www\.mydomainegypt-holidays\.com|www\.mydomainsouth-africa-holidays\.co.uk|www\.mydomainsouth-africa-holidays\.com|www\.mydomaindubai-holidays\.co.uk|www\.mydomaindubai-holidays\.com|www\.mydomainoman-holidays\.co.uk|www\.mydomainoman-holidays\.com|www\.mydomainmaldives-holidays\.co.uk|www\.mydomainmaldives-holidays\.com|www\.mydomainsri-lanka-holidays\.co.uk|www\.mydomainsri-lanka-holidays\.com|www\.mydomainseychelles-holidays\.co.uk|www\.mydomainseychelles-holidays\.com|www\.mydomainmauritius-holidays\.co.uk|www\.mydomainmauritius-holidays\.com|www\.mydomainhong-kong-holidays\.co.uk|www\.mydomainhong-kong-holidays\.com|www\.mydomainthailand-holidays\.co.uk|www\.mydomainthailand-holidays\.com|www\.mydomainbali-holidays\.co.uk|www\.mydomainbali-holidays\.com)).+
RewriteRule .*\.(?:gif|jpg|png) /images/resource/block.gif [I,O]
Back to Top View papachumba's Profile Search for other posts by papachumba
 
Lexey
Moderator Group
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Online Status: Offline
Posts: 7468
Posted: 31 January 2006 at 5:26am | IP Logged Quote Lexey

>so i can start with something like condition below? note that we own both .com and .co.uk for these domains
 
Better start with:
 
RewriteCond Referer: (?!https?://www\.mydomain\.co(?:m|\.uk)).+
RewriteRule .*\.(?:gif|jpg|png) /block.gif [I,O,L]
 
>and another question, is block.gif a file that gets displayed if the rule is enforced?
 
Yes.


__________________
With best wishes,
Alex Ostapenko,
Helicon Tech.
Back to Top View Lexey's Profile Search for other posts by Lexey
 
Lexey
Moderator Group
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Online Status: Offline
Posts: 7468
Posted: 31 January 2006 at 5:34am | IP Logged Quote Lexey

>hi, i tried adding the rules mentioned in my previous post, but it seems that there is a problem coming into the sites from anywhere outside the server, like google for example.
It displays the blocking image on all the graphics.
 
What do you mean by "coming into the sites from anywhere outside the server"?
 
>here are the rules i am using, i replaced the original domain name with "mydomain" for anonimity...
The following will be a bit better:
RewriteCond Referer: (?!https?://www\.(?:mydomainholidays|mydomainholidays|mydomaincanada-holidays|...)\.co(?:m|\.uk)).+
RewriteRule .*\.(?:gif|jpg|png) /images/resource/block.gif [I,O,L]
 


__________________
With best wishes,
Alex Ostapenko,
Helicon Tech.
Back to Top View Lexey's Profile Search for other posts by Lexey
 
papachumba
Newbie
Newbie


Joined: 27 January 2006
Location: United Kingdom
Online Status: Offline
Posts: 18
Posted: 01 February 2006 at 7:25am | IP Logged Quote papachumba

Hi, i tried your solution it works perfect.
I have one final question,
is it possible to allow hotlinking for an IP in addition to my existing rules?

We currently have a content management system on our intranet which administers the content on our sites. Editors continually hotlink images in content from our range of sites. Problem is, now when they try to edit the content pages all the hotlinked images show as block.gif.
I need to either add the IP of our LAN or some other method to allow these images to show?
p.s. Content management system, the database & the engine is sitting locally on the lan. When the content is viewed on the site, it works fine because referer is always from within the list of rules in that instance. When its viewed from within the lan, we have problems.
Back to Top View papachumba's Profile Search for other posts by papachumba
 
papachumba
Newbie
Newbie


Joined: 27 January 2006
Location: United Kingdom
Online Status: Offline
Posts: 18
Posted: 02 February 2006 at 8:44am | IP Logged Quote papachumba

bump?
Back to Top View papachumba's Profile Search for other posts by papachumba
 
Lexey
Moderator Group
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Online Status: Offline
Posts: 7468
Posted: 02 February 2006 at 11:40am | IP Logged Quote Lexey

Suppose, 192.168.100.* is your LAN address space. Rule will be as follows:

RewriteCond %REMOTE_ADDR (?!192\.168\.100\.).*
RewriteCond Referer: (?!https?://www\.(?:mydomainholidays|mydomainholidays|mydoma incanada-holidays|...)\.co(?:m|\.uk)).+
RewriteRule .*\.(?:gif|jpg|png) /images/resource/block.gif [I,O,L]
Back to Top View Lexey's Profile Search for other posts by Lexey
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum