Table of Contents
Disable external WordPress comment requests
Updated May 4th, 2021 at 15:38 BST
You can disable external comment requests for WordPress. The following steps block requests to the wp-comments-post.php file that come from outside your WordPress site, which can help prevent comment SPAM.
You should always backup your site before making any changes.
Connect to your hosting with FTP or navigate to your Managed WordPress Dashboard then go to Tools and click on Open next to File Browser.
Locate the .htaccess file
Edit the file and add the following code:
RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} .wp-comments-post\.php*
RewriteCond %{HTTP_REFERER} !.*yourdomain.com.* [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule (.*) http://%{REMOTE_ADDR}/$ [R=301,L]
Save and upload the updated file
Now it will be more difficult for comment SPAM bots to post on your WordPress pages and posts.