Greenguy's Board

Greenguy's Board (http://www.greenguysboard.com/board/index.php)
-   Newbie Questions (http://www.greenguysboard.com/board/forumdisplay.php?f=5)
-   -   Little .htaccess help (http://www.greenguysboard.com/board/showthread.php?t=20896)

Boogie 2005-06-15 06:22 PM

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?

cd34 2005-06-15 06:27 PM

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.

Boogie 2005-06-15 06:35 PM

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]

cd34 2005-06-15 06:36 PM

you want to put the [NC,OR] on all lines except the last one

Boogie 2005-06-15 06:39 PM

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!

swedguy 2005-06-15 06:39 PM

Also the / in the domain should be a \

Boogie 2005-06-15 06:42 PM

ok fixed both! :D

Xeno 2005-06-15 09:20 PM

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...


All times are GMT -4. The time now is 12:04 PM.

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