How to block spam using .htaccess in WordPress

Tutorial By:
Team Zdidit

Reviewed by:
On January 28, 2016
Last modified:March 16, 2017


Spam is a nusense that you have to deal with on your website, although you can use anti spam features but manual spam can still be there, Learn how to block spam using .htaccess file in WordPress.

Blocking a specific IP can really become useful during the case when you are getting a lot of spam from a specific IP, if you are getting spam from an IP then this tutorial can really be handy. If you are using WordPress then you can use .htaccess file to block specific IP that is Giving you spam.

Getting an anti-spam plugin can be useful for your website to get rid of Spam that you have to take care of personally. Even though getting a anti-spam plugin can be helpful but when it comes to manual spam then you have then people gets over these auto spam detectors, Anti-spam usually block the bots and put a captcha to filter the spammers from others, but this things won’t work on manual spammers.

This can be really useful when you find that someone giving you spam, All you have to get is the IP of the person. This Fairly easy to get the IP of the comments that is spreading spam on your WordPress website, every WordPress comment stores IP in the comment section of the Admin Panel of your Website.

Lets start to block spam using .htaccess in WordPress

After getting the IP you have to go to your .htaccess file in the root directory of your website hosting, and you have to put the below code there.

<Limit GET POST>
 Require all granted
 Require not ip

With apache 2.4 and above servers you have to use the above code to restrict the IP, You can add more IP to the list By adding “require not ip 555.66.77.888” to the code and upload the file to the servers.

<Limit GET POST>
 Require all granted
 Require not ip
 Require not ip 555.66.77.888

More IP like to block add the “Require not ip” replace xxx with IP that you want to add to the list of IP you would like to block.

Now save the code in the file and upload to the server. You are good to go, the IPs will be blocked and when someone will try to access your website.

More tutorials:

If you liked the post then please share it, and to ask a question or for starting a conversation use the comment section below.

You can follow us on twitter, facebook, Google+

Team Zdidit

Team Zdidit take care of all the content creation for zdidit. This team is supervised by Achin Verma

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *