[Solved] wp-comments-post.php 405 Error In Google Webmaster tool
In this article, we will learn how to fix wp-comments-post.php 405 Error In the Google Webmaster tool. Almost all people who are running a website will face this issue in google console. Even on my website, I received 405 errors in https://www.gomahamaya.com/wp-comments-post.php
You may also be interested in FOMO Plugins, email marketing service, and Lead generation Plugins
Basic Concept
Before I start explaining how to fix that error you need to understand that some files in WordPress are core files. Which shouldn’t be accessible to anyone in order to maintain the security of your website . for example wp-comment-post.php. If you will look into codes of wp-comment-post.php it says if anyone requests this file return 405. This file is basically responsible for managing comments on your WordPress website.
You may also be interested in FOMO Plugins, email marketing service, and Lead generation Plugins
Code Snippet
if ( 'POST' != $_SERVER['REQUEST_METHOD'] ) { $protocol = $_SERVER['SERVER_PROTOCOL']; if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ) ) ) { $protocol = 'HTTP/1.0'; } header('Allow: POST'); header("$protocol 405 Method Not Allowed"); header('Content-Type: text/plain'); exit; }
Steps required to fix 405 error in Google console
- Login to google webmaster and select your domain. Then click on Crawl.
- Now click on robots.txt Tester and paste the following code.
Disallow: /wp-comments-post.php
3. By uploading that code you are saying google robots not to fetch the data inside disallowed files
Now Bingo guys no more wp-comments-post.php 405 Error In Google Webmaster tool
Thanx bro
Very useful information. This has helped fix my website.
Hi dharmendra i am really glad to hear that you find it useful
regards,
Rahul