WordPress Comments Return 404 Fix

When your WordPress Setup returns 404 error response for your comments. There are several reason why that might happen and how to fix it. I first realized that I had issue with one of my site, since I was expecting some comments based on the amount of traffic that I receive. However, after going through all of the troubleshooting steps, I finally realized that the problem was with my cookie cutter htaccess file that was with a huge error.

This blog post is written to help those people who got stumped with the WordPress post comments that returned 404 error.

1. Troubleshoot 1 – Faulty Permalink structure.

It appears to be most common that there are some empty spaces in the permalink structure that causes posting of comments to fail. To fix this possibility, reset the WordPress permalink and change it to permalink. Make sure all the spacing is correct.

2. Troubleshoot 2 – Deleted wp-comments-post file

The WordPress comments posting system is mainly based on the file wp-comments-post.php that are found under the public htm section of your server. If it gets deleted somehow via the file manager or FTP access, you will experience comments posting that generate 404 error.

3. Troubleshoot 3 – Broken Theme

Sometimes it is not you that caused the error. It could be incompatibility between older themes and WordPress upgrades that cause comment posting to return 404. To check for this possibility, install another theme to see if the issue persists. If the theme is the problem, you may have to dig deeper into the code to see if you can find any fixes. Or changing the WordPress theme may be an easier way to go.

4. Troubleshoot 4 – Faulty .htaccess code for wp-comments-post.php protection.


RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} .wp-comments-post\.php*
RewriteCond %{HTTP_REFERER} !.*EXAMPLE.com.* [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule (.*) http://%{REMOTE_ADDR}/$ [R=301,L]

To help combat spam, I have placed this snippet of code in my htaccess file. This file basically 301 redirects the visitors from posting comments if they are not from your site. The purpose is that some spam bots post directly to wp-comments-post page without even accessing your page. With this htaccess code, it can help with the server load since the server will not process the majority of the comments from bots.

Now, this is where my WordPress 404 comments come about. I forgot to change “.*EXAMPLE.com.*” to my actual website. This causes my server to reject all comments and send them back to their referring pages. After change EXAMPLE to my actual domain, I have fixed my WP comments 404 error.

Leave a Reply

Your email address will not be published.