[Solved] wp-comments-post.php 405 Error In Google Webmaster tool
In this articles we will learn how to fix wp-comments-post.php 405 Error In Google Webmaster tool . Almost people who is running a website will face this issue in google console . Even in my website i received 405 error 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 shoudn’t be accessible to any one in order to maintain 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 request 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 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