How To Stop Spam Comments on WordPress Using .htaccess File – Shamsher Khan

How To Stop Spam Comments on WordPress Using .htaccess File

One of the biggest challenges which you face running a blog is fighting spam of various types. One of the most common types of spam is comment spam and when it comes to WordPress  Blog we have many ways to fight comment spam and spammer.

One of the best ways is by using Akismet WordPress plugin by WordPress itself.

You can get the Akismet WordPress plugin from here and learn how to get a free API key for the Akismet plugin on the same website.

So,  at the same time when you will see your comment spam page, you might find few IPs are constantly sending comments spam.

The easiest way to get rid of these spam comments is by blocking their IP address using the .htaccess file method. I highly recommend keeping a backup of your .htaccess file before editing it.

Htaccess file is located at the root of your WordPress installation Directory and you can either use SEO by Yoast plugin > Edit files to edit your .htaccess file or you can follow this guide which I have mentioned below to make changes in your .htaccess file.

Make sure you take a backup of your .htaccess file before making any changes, as even a single wrong character will make your site inaccessible and you may not able to live your website for a while if you are not technical.

That is why I am saying to keep a backup first before any editing in the .htaccess file.

Here is the code that you need to enter in your .htaccess file, and upload/save it.

<Limit GET POST>

order allow, deny

deny from

allow from all


You can always enter more IPs by adding one more line below this line.

deny from

You can get the IP of the spammer in your spam comment page, under the WordPress Login dashboard I find this way to be the best way to fight against the lots of spam from bots.

Hope this will help you to fight spam for more tutorials and tricks don’t forget to subscribe to us.

Also read: Thrive Comments Review

About the Author Mrigakshi Choudhary

Composing Professional expressing her potential for enhancing the quality of the digital world. Functioned as a research reporter for an administration undertaking.

follow me on: