How to block spam using .htaccess 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 220.127.116.114 </Limit>
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 518.104.22.1688” to the code and upload the file to the servers.
<Limit GET POST> Require all granted Require not ip 22.214.171.1244 Require not ip 5126.96.36.1998 </Limit>
More IP like to block add the “Require not ip xxx.xxx.xxx.xxx” 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.
- How to add Nofollow tag to menu links in WordPress
- How to block access to directories in WordPress
- How to restrict authors to a specific category in WordPress
- Guide to add custom login URL in WordPress
If you liked the post then please share it, and to ask a question or for starting a conversation use the comment section below.