Greenguy's Board


Go Back   Greenguy's Board > Programming & Scripting
Register FAQ Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 2004-08-10, 10:10 AM   #1
benek
Aw, Dad, you've done a lot of great things, but you're a very old man, and old people are useless
 
Join Date: May 2004
Posts: 25
special anty hotlink

hi

i need such antyhotlink that from other domain hotlink will impossible but from my own domain will possible?

do you know how to do this?
benek is offline   Reply With Quote
Old 2004-08-10, 11:23 PM   #2
Anothers
If something goes wrong at the plant, blame the guy who can't speak English
 
Join Date: Jan 2004
Location: Poland
Posts: 30
it's easy with htaccess

Code:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$ [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://cgi.(aol\.)?ebay\.com [NC]
RewriteCond %{HTTP_REFERER} !^(wy[sc]iwyg://[0-9]*/)?http(s)?://YOUR_SITE_IP [NC]
RewriteCond %{HTTP_REFERER} !^(wy[sc]iwyg://[0-9]*/)?http(s)?://YOUR_SITE_DOMAIN [NC]
RewriteCond %{HTTP_REFERER} !^(wy[sc]iwyg://[0-9]*/)?http(s)?://OTHER_SITE_DOMAIN [NC]
RewriteRule \.(bmp|gif|jpe?g)$ - [F,L]
where
YOUR_SITE_IP = your server ip 123.123.123.123
YOUR_SITE_DOMAIN = www.my_cool_domain.com

OTHER_SITE_DOMAIN - other domain that you allow hotlink
Anothers is offline   Reply With Quote
Old 2004-08-11, 08:18 AM   #3
dgraf
If something goes wrong at the plant, blame the guy who can't speak English
 
Join Date: Jul 2004
Posts: 30
All the rules are trickable as they are shown here and almost everywhere on the web. Always terminate the condition line by something like this --

Code:
	(/|\?|$)
Example --

Code:
RewriteCond %{HTTP_REFERER} !^(wy[sc]iwyg://[0-9]*/)?http(s)?://YOUR_SITE_IP(/|\?|$) [NC]
Otherwise the referer can by tricked by passing referer like this one -
http://www.yourdomain.com.my-evil-hotlinkingdomain.com

It is not a problem to setup a vhost which will fit your regexp needs and this mistake is the worse since it is highly predictable.

Another good idea should be allowing access to pictures from image searches and probably from local stored pages too.

Code:
# Allow Saved Pages
RewriteCond     %{HTTP_REFERER} !^file://.*$                                    [NC]

# Search Engines
RewriteCond     %{HTTP_REFERER} !^http://([^/]*\.)?google\.(.{2}\.)?.{2,3}/.*$  [NC]
RewriteCond     %{HTTP_REFERER} !^http://([^/]*\.)?yahoo\.(.){2,3}/.*$          [NC]
RewriteCond     %{HTTP_REFERER} !^http://216\.239\.59\.104/.*$                  [NC]
RewriteCond     %{HTTP_REFERER} !^http://64\.233\.161\.104/.*$                  [NC]
RewriteCond     %{HTTP_REFERER} !^http://66\.102\.7\.104/.*$                    [NC]
RewriteCond     %{HTTP_REFERER} !^http://64\.233\.167\.104/.*$                  [NC]
RewriteCond     %{HTTP_REFERER} !^http://216\.239\.41\.104/.*$                  [NC]
RewriteCond     %{HTTP_REFERER} !^http://216\.239\.39\.104/.*$                  [NC]
(just example without editing)

Oh my god I did it! My first post here ...

(edited to add the code tags)

Last edited by dgraf; 2004-08-11 at 08:23 AM..
dgraf is offline   Reply With Quote
Old 2004-08-11, 07:40 PM   #4
Anothers
If something goes wrong at the plant, blame the guy who can't speak English
 
Join Date: Jan 2004
Location: Poland
Posts: 30
yeap

dgraf is right about that ("always terminate the condition line")

EDITED:
it can be easy tricked with vhosts when there is no termination
Anothers is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:52 PM.


Mark Read
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc