Greenguy's Board

Greenguy's Board (http://www.greenguysboard.com/board/index.php)
-   Programming & Scripting (http://www.greenguysboard.com/board/forumdisplay.php?f=15)
-   -   Block certain domains via htacess (http://www.greenguysboard.com/board/showthread.php?t=30228)

Jel 2006-03-28 12:42 AM

Block certain domains via htacess
 
Hi Guys,

This musta been asked before but I can't track the answer down using the search function, apologies.

I have a few domains sending me worthless traffic to galleries they have picked up from TGP's and I want to block their traffic. I googled and got:

order allow,deny
deny from .domain.com
deny from .domain.com
deny from .domain.dk
allow from all

which didn't work, so I tried:

order allow,deny
allow from all
deny from .domain.com
deny from .domain.com
deny from .domain.dk

but no dice there either - wrong instructions, or dumb mistake somewhere?

Thanks in advance :)

btw what should I be seeing when I click a link from those place - 403 forbidden or...?

xxxtreme 2006-03-28 03:32 AM

You could try something like this:

RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http(s)?://(www\.)?domain1.com.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http(s)?://(www\.)?domain2.com.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http(s)?://(www\.)?domain3.com.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http(s)?://(www\.)?domain4.com.*$ [NC]
RewriteRule .* http://www.google.com [R,L]


Does a great job on my sites :)
Btw, I got this from: http://www.htaccesstools.com/block-hitbots/

cd34 2006-03-28 10:34 AM

the reason your earlier rules didn't work is that you were blocking the 'host' machine of domain.com from accessing your site. So, had their webserver tried to hit your server, they would have been blocked. This wasn't what you wanted.

In addition, by putting deny from domain.com in your .htaccess, you now forced apache to do a DNS lookup for EVERY request below that .htaccess -- that reverse dns lookup can really slow things down on a busy site.

The Rewrite Rules posted by xxxtreme look at the referrer as sent by the surfer's browser. I would suspect that is what you were really after.

if indeed it is a hitbot and not some form of hotlinking or unwanted traffic, your first rules would be correct, however, based on your test and stated results, I think you wanted to block the referrer, not the server.

Jel 2006-03-29 02:03 AM

Thanks guys,

Took me a couple of reads but I think I got it. It's german and some other unproductive foreign traffic from foreign TGPs, so I'm gonna use your rules xxxtreme :)

Jel 2006-03-29 02:13 AM

Hmm, can't get this to work - I have:

RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http(s)?://(www\.)?fatfred.com.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http(s)?://(www\.)?i5sex.com.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http(s)?://(www\.)?gratis6.dk.*$ [NC]
RewriteRule .* google.com [L]

But can still get to my galleries from their pages.

*edited to add:

Just noticed the code I was generated differed slightly to the example posted by xxxtreme so I made it [R,L] on the bottom line, but that hasn't cured it, so I'm stuck lol.

stuveltje 2006-04-11 04:02 PM

i use this to redirect sites i dont wanna have traffic from
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://fusker.lewww.com/.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://babes.coolios.net/.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://fusker.org/.*$ [NC]
RewriteRule \.(jpg|gif)$ http://www.some of your sponsor paysites or 404.com/ [R,L,NC]



most of the time i put in the last domain a paysite url that way i dont burn the bandwidth, i had to do it last time with some japanese tpg linksite who linked one of my squirting galleries

Jel 2006-04-29 01:45 AM

aaargh this is driving me crackers lol, ok here is what I have,

RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://fode-me.com/.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://fatfred.com/.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://gratis6.dk/.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://5isex.com/.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://i5sex.com/.*$ [NC]
RewriteRule \.(jpg|gif)$ http://www.google.com/ [R,L,NC]

But when I check the links on those pages I get taken to my domain, not google - I'm stumped :(

Jel 2006-04-29 01:56 AM

So I changed the last line thinking the gif|jpg rule may be referring to hotlinking, this is now what I have, and still does not work:

RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://fatfred.com/.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://fode-me/.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://5isex.com/.*$ [NC]
RewriteRule .* http://www.google.com [R,L]

Maj. Stress 2006-04-29 03:09 AM

clear your cache?

cd34 2006-04-29 06:05 AM

RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://(.*\.)?fatfred.com [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.*\.)?fode-me [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.*\.)?5isex.com [NC]
RewriteRule .* http://www.google.com [R,L]

you would have blocked http://fatfred.com from linking to you, but not http://www.fatfred.com.

you can also do something like:

RewriteEngine on
RewriteCond %{HTTP_REFERER} fatfred.com [NC,OR]
RewriteCond %{HTTP_REFERER} fode-me [NC,OR]
RewriteCond %{HTTP_REFERER} 5isex.com [NC]
RewriteRule .* http://www.google.com [R,L]

which will block www.123fode-me234.com

Jel 2006-04-30 02:14 AM

No idea why it won't work still, tried that new rule sparky, still no joy. Wasted too much time on this so I'm gonna forget about it. Thanks for all your time people :)


All times are GMT -4. The time now is 07:13 PM.

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