Forum Moderators: phranque
My log is contaminated with a large number of spam url.
I try to edit a Htaccess file to block them, but it doesnt work at all.
Below is a copy of my file.
Can you tell me how can I make it work?
thanks,
Yagera
-------
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR]
<snip>
RewriteCond %{HTTP_USER_AGENT} ^Zeus
RewriteRule ^.* - [F,L]
Deny from 80.65.***.162
Deny from 212.117.***.70
Deny from best-phen**rmine.com
<snip>
deny from fr**prizes.com
deny from d**u.net
# Drugs / Herbal
RewriteCond %{HTTP_REFERER} (sleep-?deprivation) [NC,OR]
<snip>
RewriteCond %{HTTP_REFERER} (tr***dol) [NC]
RewriteRule .* - [F]
# Adult
RewriteCond %{HTTP_REFERER} (adult) [NC,OR]
<snip>
RewriteCond %{HTTP_REFERER} (housewives) [NC]
RewriteRule .* - [F]
# Weight
RewriteCond %{HTTP_REFERER} (fat-) [NC,OR]
<snip>
RewriteCond %{HTTP_REFERER} (supplement) [NC]
RewriteRule .* - [F]
# Gambling
<snip>
RewriteCond %{HTTP_REFERER} (casino) [NC,OR]
RewriteCond %{HTTP_REFERER} (blackjack) [NC]
RewriteRule .* - [F]
# Loans / Finance
RewriteCond %{HTTP_REFERER} (mortgage) [NC,OR]
<snip>
RewriteCond %{HTTP_REFERER} (pay-?day) [NC]
RewriteRule .* - [F]
[edited by: jdMorgan at 3:50 pm (utc) on Dec. 18, 2005]
[edit reason] No URLs, IPs, Trademarks, or code dumps, please. See TOS and Apache Charter. [/edit]
There are several problems here, at several levels.
First, blocking these visitors will not keep them out of your logs or stats. Their requests will still show, but with a 403-Forbidden response code. Over time, they *may* stop making requests to your site, but there is no guarantee of this. Just to be sure your expectations are not too high, here...
Second, You're starting out with a huge complex file. Why not start small, test, and add code a bit at a time so that when something breaks, you know where the problem is.
Next, there are apparently spaces ahead of many of the lines, and this is not legal syntax. .htaccess code must be exact, and no latitude is allowed for 'style' or formatting changes.
Also, it has yet to be established whether you can even run mod_rewrite code on your server. So again, a small test is in order.
Finally, the phrase "it does not work" provides us with almost no information to help you. How does it not work? - Does nothing happen at all? Does your server stop serving pages and return a 500-Server Error for all requests? What appears in your server error log when you test the code? Answers to all of these questions are needed if we are to be of any help.
Try this test:
RewriteEngine on
RewriteRule ^foo\.html$ /index.html [L]
If you get a server error, try adding this line:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^foo\.html$ /index.html [L]
After you get a small part working, then you can add a few more lines and test again. Don't try to do this all at once until you are more comfortable with it.
For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].
Jim