After several months of fighting with manual comment spam, I have decided to block all the traffic coming from India. All they do is just post useless comments everyday, which made me wonder if its their job to post spam.
Anyway, blocking people by IP is very straight forward using htaccess. I will show two ways on how we can block browsers based on their
IP addresses.
Blocking by IP block is not a very good idea because you will also block legitimate traffics too. Normally, you will do this in at least a week duration and then lift the restriction back to normal.
India's IP block that is
spamming me non-stop is122.180.0.0. Adding the following code below to the htaccess, blocks all traffic coming from that IP block. You can also block specific IP by writing its entire IP address.
order allow,deny
deny from 122.180.
deny from 123.123.123.123
allow from all
Redirect Traffic to a specific page
Redirecting the traffic to a page might be useful instead of just giving them the 403 error page. What is did is to redirect all the traffic from India to a Rick Rolled YouTube page, lol.
RewriteCond %{REMOTE_ADDR} ^122\.180\.\d+\.\d+$
RewriteRule .* http://www.youtube.com/watch?v=ZOU8GIRUd_g [R=302,L]
R=302 is a status code for temporary redirect and L stands for Last as in the last line. You can add more RewriteCond IP addresses by inserting an addtional line before the RewriteRule Line.
Hello Alfredo Sanchez,
I really appreciate your every post and the time you expand for sharing informative informations with your visitors.
And feel Sorry about those India's IP Spammer who spamming your blog.