Greenguy's Board


Go Back   Greenguy's Board > Newbie Questions
Register FAQ Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
Old 2008-07-10, 09:37 AM   #7
cd34
a.k.a. Sparky
 
cd34's Avatar
 
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
Depending on your directory structure:

Create a directory of files that are hotlinkable universally and put

RewriteEngine off

in the .htaccess in that directory

Then, you can protect your main site with rewrite rules:

Code:
RewriteEngine on
# leave this line in allow empty referrers, remove to disallow empty referrers
RewriteCond %{HTTP_REFERER} !^$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.*@)?([a-z0-9-]+\.)*yourdomain\.com(:[0-9]+)?(/.*)?$ [NC]
RewriteRule .*\.(asf|mpg|mpeg|wmv|avi|rm|gif|jpeg|jpg|zip)$ - [NC,F,L]
replace yourdomain with your domain name.

Blocking domains in your .htaccess like

deny from *.chinesesitename.com

won't do what you need -- and will only slow down page requests because each IP address that hits your site would need to do a reverse lookup. I don't know if that is what you've done, or, if you are putting in mod_rewrite rules to specifically block domains.

You could also do the reverse and do something like:

Code:
RewriteEngine on
RewriteCond %{HTTP_REFERER} (domain1\.com|domain2\.com|domain3\.com) [NC]
RewriteRule .* - [F]
which would be a block based on the incoming referrer.

My suggestion would really be to disallow hotlinking except for domains that you want to allow hotlinking for which prevents this sort of thing from happening in the future, and, stops the immediate problem without you having to search through logs or referrers to figure out who is hotlinking.

If you want to allow multiple sites to hotlink, you can put lines like:

Code:
RewriteCond %{HTTP_REFERER} !^http://(.*@)?([a-z0-9-]+\.)*yourdomain\.com(:[0-9]+)?(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.*@)?([a-z0-9-]+\.)*yourseconddomain\.com(:[0-9]+)?(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.*@)?([a-z0-9-]+\.)*yourotherdomain\.com(:[0-9]+)?(/.*)?$ [NC]
You can consolidate that a bit, but, I think that makes the rules a bit confusing to troubleshoot later on.
__________________
SnapReplay.com a different way to share photos - iPhone & Android
cd34 is offline   Reply With Quote
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 04:49 PM.


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