Block specific Visitors from visiting your site, Who try to Harm your reputation..!
Yes, you read it right. There will be always some people who will try to Harm your Reputation by posting abusive and spam comments in your blog.And The worst part may be clicking your Adsense ads or other ads and trying to get you Banned due to click fraud.Yes You can always use WordPress plugins to Stop Spam comments but if you want to Block certain visitors from a specific IP address this Htaccess trick will be useful.
Note : This trick is applicable for blogs On a self Hosted Platform (e.g Self Hosted WordPress or static websites) .Blogs that are Hosted on Free Hosting accounts like Blogger or WordPress.com won’t be able to use this trick as they Do not have access to their FTP.
How to Know the IP address of the Spam Commentator:
If you are Using WordPress then Log in to your dashboard and go to the comments panel. You will see the IP addresses of all Your commentators there.
If you are not using WordPress then you can check your server logs (like awstats) to get a more detailed information about the Spam commentator. You can also Use StatCounter for finding the IP addresses but the server logs and WordPress data are more than sufficient.
How to Block The Spam Commentator from Visiting your blog:
Okay Once the IP is determined you are all set to block the Spam commentator.Following are the steps involved :
1. Open Your FTP account using any of the FTP programs and go to your Website’s Root directory.
2. You will see a .htaccess File in the root directory. Download that File into your computer. In some FTP programs by default the htaccess file is hidden so may have to enable showing of Hidden files.
3. Once you have the .htaccess file in your computer create a back up of that file so that you can restore things if something goes wrong during the blocking process.
4. Open the .htaccess file in notepad for editing and add the following lines anywhere at the end of all the content:
<Limit GET POST PUT>
order allow,deny
allow from all
deny from xx.xx.xx.xx
</Limit>
replace xx.xx.xx.xx with the IP address of the commentator that you have extracted from WordPress or from your server logs.
5. To block multiple IP addresses from Visiting your blog You can always add another line just below the deny from Line and add another IP address. Here is an example explaining that issue :
<Limit GET POST PUT>
order allow,deny
allow from all
deny from xx.xx.xx.xx
deny from yy.yy.yy.yy
deny from zz.zz.zz.zz
</Limit>
6. Save your new Htaccess file and upload it to your Root directory.
7. If your site goes down or something Silly Happens Then probably you had done something wrong. Restore the backup as you had created in step 3 and leave a Comment here so that we can look down into what problems you are having.
If all goes well you will not see any change reflected in your site but the commentator won’t be able to visit that site from that specific IP address. So If anyone is Posting Vulgar comments or click bombing your site do not grant him access and permanently block him from harming your blog.
Did this Method worked for you ? Do you have any better Idea ? Do share with us in the comments! Happy Blogging!!
Related posts:































Nice information….I heard about lots of fraud case about clicking on ADs. I will try on my blog too . Thx
Click Fraud is on rock now..Need to be very careful
Good tips, however, most of these IPs are spoofed,used from a proxy or the spammers use dynamic IPs. In this case, blocking IPs does not have any effect.
We can’t Do anything about dynamic ips..but we can restrict to some range..
First thing we need to do to stop spam is just use a simple math fun to answer. then this the secondary way..
Thanks Alot I was looking for this , as there is lot of spamming done on my blog from same set of ip’s i will surely use this information.
Good you found it useful. Thanks for your comments…
Normally I will use IP Deny Manager in Cpanel. That’s very very easy Lax.
May be easy but always you need to capnel…Thanks for reminding the other way…
@ Tech @ InkAPoint : Using Ip deny manager is Useful but it has a serious problem. You cannot ban a bunch of IP’s like the following :
deny from 123.123.123
Another problem may be the IP deny manager can overwrite your current htaccess settings On some occasions which may lead into problems ( it did for me…)
Thanks Lax for sharing !… Keep rocking
That’s great. Thanks for your answer dude…
Nice post details.
I remember blocking an IP cause of spamming and then another user complained about not be able to access my site. It was actually my fault as I used the ‘*’ like 124.98.9.*
That’s funny
That can happen to anyone..But to be frank i didn’t blocked any IP till now..Planning to ban few IP from which i get too many spams..
I agree with Richael. If a spammer is determined to degrade you or your blog. He/She will try some other means.
No one will target only specific person or blog i think. They will just try to spam the weak blog, if you take all these precautions then they will think it will not work with you
Good tips here. I’ve had someone try to click on my Google ads over and over to get me Banned. I simply contacted Google and told them I noticed a sudden jump in revenue. They fixed the problem for me.
That’s great you have done that…One of my friends account got disable for the click fraud reason.
He called and told that he got $60 in one day…I suspected at the moment…But heard the bad news on the next day..!
Yeah, that is unfortunate. Did he contact Google once he was Banned? Did they reactivate his account?
He contacted Adsense team immediately explaining the situation..But they didn’t considered his request.
Google cares/considers the request only for named bloggers or sites.
That’s unfortunate for him..that he lost $200 in the a/c, which he made for genuine clicks.
can Do it in cpanel deny ip ?.
Yes you can Do it from there..But its not possible to block a group/range of ips there..
@ Lax
That is VERY unfortunate. I think Google needs to come up with a work around for that. Very unfair.
Is that Avril Lavigne? I didn’t know she spams now
Seriously I think I got the same spammer before. Anyways thanks for sharing this, this can be useful someday. About Adsense, Google should be investigate first about click fraud because anyone can just shut you down by doing a click bomb on your ads.
We can’t expect anything from Google. We need to alert always
This tips seems helpful to all WordPress users. I think I should try how to block spam commentators in blogspot blogs.
Thanks for the idea.