Reply to Re: Block Referrers not working

Your name:

Reply:


Posted by J.O. Aho on 12/09/06 09:44

Shooter wrote:
> I'm trying to find a way to block a bandwidth thief who is sending a TON of
> hits to one page on one of my sites. Thus far nothing I've tried has
> worked - the .htaccess files totally block everyone from the page, rather
> than just the specific referring website. Running Linux with PSA. Can anyone
> suggest a method that will actually work?


if you need to block a ip-number, iptable rules may be useful:
iptable -A INPUT -s x.y.z.w -d 0/0 -j DROP


PHP method to redirect the user back to the page, add this in the top:
if ($_SERVER['HTTP_REFERER']=="the referer page") {
header("Location: {$_SERVER['HTTP_REFERER']}");
}



Apache rules (not tested), we redirect them back:
RewriteMap deflector txt:/path/to/deflector.map
RewriteCond %{HTTP_REFERER} !=""
RewriteCond ${deflector:%{HTTP_REFERER}} ^-$
RewriteRule ^.* %{HTTP_REFERER} [R,L]
RewriteCond %{HTTP_REFERER} !=""
RewriteCond ${deflector:%{HTTP_REFERER}|NOT-FOUND} !=NOT-FOUND
RewriteRule ^.* ${deflector:%{HTTP_REFERER}} [R,L]


--- deflector.map ---
## from_page redirect_to_page
## redirect_to_page = '-', then error page from you
http://www.badguys.com/bad/index.html www.badguys.com/bad/stupid1.html
http://www.badguys.com/bad/index2.html www.badguys.com/bad/stupid2.html
http://www.badguys.com/bad/index3.html www.badguys.com/bad/stupid3.html
http://www.badguys2.com/bad/index.html -
--- eof ---


The fun with redirecting people back to the original site is that it generates
a quite a lot of extra logs and users may send them angry feedbacks about
broken links.


Have fun...



//Aho

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация