≡ Menu

[How-To Guide] Avoid Spam Comment In WordPress Using .htaccess

Many time you see your comment spam page and find that few particular IP’s constantly sending spam comments. Now you want to get rid of these spam comments, the easiest way is to block these IP address by using .htaccess. Already I have shared how to guide on creating .htaccess file and how to guide on editing .htaccess file. Now in this post I’m sharing how to guide on avoiding spam comments in WordPress blog using .htaccess file.

Step1: Log-in into cPanel by typing URL (mentioned below). Click on “File Manager” (as shown below):

http://www.domainname.com/cpanel (replace domainname with your own domain name)


Step2: When you click on “File Manager”, it open a new window, i.e., your root directory (as shown below).


Step3: In root directory select “.htaccess” file. Now click on “Edit” option in navigation menu as shown below:


Step4: As soon as you click on “Edit” button in navigation menu, it open a new window (as shown below)


Step5: Now copy this code and paste this code in .htaccess file (you have to paste this code in step 4):

<Limit GET POST>
order allow,deny
deny from xx.xxx.xxx.xxx
allow from all

You can get the IP address of the spammer in your comment page, under WordPress Dashboard.

Step6: After pasting this code (code you have copied in step5) in .htaccess file, click on “Save” button as shown below:


Step7: Congratulations, you have successfully avoid spam comments in WordPress using .htaccess.


Replace xx.xxx.xxx.xxx with desired IP.

If you have any query do let me know in comment section and don’t forget to like on Facebook so that you don’t miss any of the tutorials on .htaccess

{ 4 comments… add one }
  • its a great tip Vivek, thanks will check this.

    • Yaa Anish, its good thing to avoid spam comments if they are increasing in number

  • Bligbook

    i would better use an akismet plugin, because it does my total job…

    • Akismet is good but its for those who are receiving too much spam from particular IP’s

Leave a Comment