|
2005-06-15, 06:22 PM | #1 |
I like to blog :)
Join Date: Sep 2003
Posts: 1,050
|
Little .htaccess help
I am looking for some help in blocking certain domains from hotlinking (instead them getting an error image)
I know how to do a blanket redirect but not one for specific domains :? specifically I've got two sites showing up in referrals: http://www.ridgeviewelem.org/ http://www.uccpp.org/ i dont know what they are and cant find any information on them (visiting them forwards me elsewhere) and am particuarlly worried about those domains. any help? |
2005-06-15, 06:27 PM | #2 |
a.k.a. Sparky
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
|
Code:
RewriteEngine on RewriteCond %{HTTP_REFERER} ^http://(.*@)?([a-z0-9-]+\.)*firstdomain\.com(:[0-9]+)?(/.*)?$ [NC,OR] RewriteCond %{HTTP_REFERER} ^http://(.*@)?([a-z0-9-]+\.)*seconddomain\.com(:[0-9]+)?(/.*)?$ [NC] RewriteRule .*\.(asf|mpg|mpeg|wmv|avi|rm|gif|jpeg|jpg|zip)$ - [F,L] the ! in the prior rules means, if it DOESN'T equal the following. In this case, you remove the !, the rules have an implicit AND, but, you want an OR, so, if it matches firstdomain OR seconddomain, block.
__________________
SnapReplay.com a different way to share photos - iPhone & Android |
2005-06-15, 06:35 PM | #3 |
I like to blog :)
Join Date: Sep 2003
Posts: 1,050
|
thanks mate. does this look right?
RewriteCond %{HTTP_REFERER} ^http://(.*@)?([a-z0-9-]+\.)*http://www.ridgeviewelem/.org(:[0-9]+)?(/.*)?$ [NC,OR] RewriteCond %{HTTP_REFERER} ^http://(.*@)?([a-z0-9-]+\.)*http://www.uccpp/.org(:[0-9]+)?(/.*)?$ [NC] RewriteCond %{HTTP_REFERER} ^http://(.*@)?([a-z0-9-]+\.)*http://www.myspace/.com(:[0-9]+)?(/.*)?$ [NC] RewriteCond %{HTTP_REFERER} ^http://(.*@)?([a-z0-9-]+\.)*http://www.xanga/.com(:[0-9]+)?(/.*)?$ [NC] RewriteCond %{HTTP_REFERER} ^http://(.*@)?([a-z0-9-]+\.)*http://www.penny-arcade.com(:[0-9]+)?(/.*)?$ [NC] RewriteRule .*\.(asf|mpg|mpeg|wmv|avi|rm|gif|jpeg|jpg|zip)$ - [F,L] |
2005-06-15, 06:36 PM | #4 |
a.k.a. Sparky
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
|
you want to put the [NC,OR] on all lines except the last one
__________________
SnapReplay.com a different way to share photos - iPhone & Android |
2005-06-15, 06:39 PM | #5 |
I like to blog :)
Join Date: Sep 2003
Posts: 1,050
|
done. thanks mate. was worried about kids seeing stuff and penny arcade and that elementary school site are both kid related. dont want to make it any easier on those folks but at the same time i got a few hotlinking places i dont mind so much
thanks! |
2005-06-15, 06:39 PM | #6 |
Vagabond
|
Also the / in the domain should be a \
|
2005-06-15, 06:42 PM | #7 |
I like to blog :)
Join Date: Sep 2003
Posts: 1,050
|
ok fixed both!
|
2005-06-15, 09:20 PM | #8 |
Do you want the job done right, or do you want it done fast?
Join Date: Jun 2005
Location: Canada
Posts: 494
|
Not sure if you are aware of this link http://www.htaccesstools.com/hotlink-protection/ ...about htaccess for anti-hotlinking ? I know sometimes when I review submitted sites with htaccess for preventing hotlinking, they forget about the people who use anti virus and personal firewalls which often breaks all images and graphics on a website that uses this method to prevent hotlinking. The problem is blank referrers...so in my submission rules if anyone does this, I gave them that link to solve the broken site images...
|
|
|