Forum Moderators: phranque

Message Too Old, No Replies

Need to block referring site by keyword

another approach to ban log spammers

         

Storyman

6:49 am on Nov 30, 2004 (gmt 0)

10+ Year Member



After blocking hosting & referring IPs from log spammers, I thought maybe the way to tackle the problem is by using key words from the referring sites.

What little I've learned about the black art of .htaccess it seems that it is ideal for the task. Only problem is that I have no idea how to go about it. Has someone already done something smiliar that can help out with what the code should look like?

jdMorgan

7:59 pm on Nov 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The "keywords" will be in the HTTP_REFERER string, so all you need to do is to compile a list of keywords and keyword phrases that are *always* an indicator of unwelcome visits, and then test for those strings as you would test for an HTTP_REFERER. Typically, the words will be part of a query string forwarded in the Referrer, and will follow some character sequence that indicates the search query. For example I show "q=" below, and assume that the query string uses ampersands to demarcate various query parameters, like Google does.

RewriteCond %{HTTP_REFERER} ^http://www\.sitespammers-r-us\.com [OR]
RewriteCond %{HTTP_REFERER} q=[^&]*phrase\ I\ don't\ like [OR]
RewriteCond %{HTTP_REFERER} q=[^&]*badword1 [OR]
RewriteCond %{HTTP_REFERER} q=[^&]*badword2
RewriteRule .* - [F]

This may not answer your questions, but maybe it'll get you started.

Jim