Title: Prevent google from reading comment&#8230;
Last modified: August 18, 2016

---

# Prevent google from reading comment…

 *  Resolved [indiaberry](https://wordpress.org/support/users/indiaberry/)
 * (@indiaberry)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/prevent-google-from-reading-comment/)
 * How do I prevent google from reading comments on my website? I don’t mind google
   listing my site. I post an uncommon name on my website, and google track that
   word directly to my website. And since then, when I put that word in the google
   search, it come directly to my website. How do I keep google from reading my 
   comment?

Viewing 12 replies - 1 through 12 (of 12 total)

 *  [whooami](https://wordpress.org/support/users/whooami/)
 * (@whooami)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/prevent-google-from-reading-comment/#post-549452)
 * The ONLY way you can do that is by checking the user-agent and hiding content
   based on the user-agent.
 * Here’s something to get your brain in thinking mode:
 *     ```
       $useragent = $_SERVER['HTTP_USER_AGENT'];
       $google = "Googlebot";
       $isgoogle = strpos($useragent, $google);
       If ($isgoogle === false) {
       //not a Google hit
       } else {
       //This is Google
       ```
   
 *  Thread Starter [indiaberry](https://wordpress.org/support/users/indiaberry/)
 * (@indiaberry)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/prevent-google-from-reading-comment/#post-549500)
 * Where should I put that code?
 *  [whooami](https://wordpress.org/support/users/whooami/)
 * (@whooami)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/prevent-google-from-reading-comment/#post-549501)
 * _“Here’s something to get your brain in **thinking** mode”_
 * Doesnt sound like youre thinking, sounds like you want someone to do this for
   you?
 *  Thread Starter [indiaberry](https://wordpress.org/support/users/indiaberry/)
 * (@indiaberry)
 * [19 years ago](https://wordpress.org/support/topic/prevent-google-from-reading-comment/#post-549539)
 * Should it go in the .htaccess file? Does it go in the index.php of the theme?
   Could I have a little more hint?
 *  [Pravin Paratey](https://wordpress.org/support/users/pravin/)
 * (@pravin)
 * [19 years ago](https://wordpress.org/support/topic/prevent-google-from-reading-comment/#post-549541)
 * That is php code. It can go in one of two places
 * 1. index.php, page.php, single.php, etc before the comment code
 * 2. start of comment.php
 * I’d pick 2 because it involves changing only 1 file.
 *  Thread Starter [indiaberry](https://wordpress.org/support/users/indiaberry/)
 * (@indiaberry)
 * [19 years ago](https://wordpress.org/support/topic/prevent-google-from-reading-comment/#post-549586)
 * Hi! When I tried the code, the words show up on the page. How do I insert the
   code. I know how to edit a file. But what I don’t know is if I need to put the
   code in this <php ?>
 *  Thread Starter [indiaberry](https://wordpress.org/support/users/indiaberry/)
 * (@indiaberry)
 * [19 years ago](https://wordpress.org/support/topic/prevent-google-from-reading-comment/#post-549587)
 * It is just that I put that code in the comment.php, it show up on the page of
   where the comments are. I am wondering what is the best way to insert the code?
 *  Thread Starter [indiaberry](https://wordpress.org/support/users/indiaberry/)
 * (@indiaberry)
 * [19 years ago](https://wordpress.org/support/topic/prevent-google-from-reading-comment/#post-549593)
 * I need a bit more help with this code, please.
 *  [adam-](https://wordpress.org/support/users/adam-/)
 * (@adam-)
 * [19 years ago](https://wordpress.org/support/topic/prevent-google-from-reading-comment/#post-549594)
 * Put it all inside <? php ?> tags and tbh I haven’t looked into it but if theres
   something like include(comments.php) then put the comments include in the // 
   not a google hit. Oh, and I’m not a php coder but it’s something like that ^^
 * Adam
 *  Thread Starter [indiaberry](https://wordpress.org/support/users/indiaberry/)
 * (@indiaberry)
 * [19 years ago](https://wordpress.org/support/topic/prevent-google-from-reading-comment/#post-549597)
 * When I put this in:
    <?php $useragent = $_SERVER[‘HTTP_USER_AGENT’]; $google 
   = “Googlebot”; $isgoogle = strpos($useragent, $google); If ($isgoogle === false){//
   not a Google hit } else { //This is Google ?>
 * I get:
    Parse error: syntax error, unexpected $end in /home/domainname/public_html/
   writer/wp-content/themes/girl/comments.php on line 113
 *  [whooami](https://wordpress.org/support/users/whooami/)
 * (@whooami)
 * [19 years ago](https://wordpress.org/support/topic/prevent-google-from-reading-comment/#post-549598)
 *     ```
       <?php $useragent = $_SERVER['HTTP_USER_AGENT'];
       $google = "Googlebot";
       $isgoogle = strpos($useragent, $google);
       If ($isgoogle === false) {
       //not a Google hit
       } else {
       //This is Google
       }
       ?>
       ```
   
 * Missing closing bracket.
 *  Thread Starter [indiaberry](https://wordpress.org/support/users/indiaberry/)
 * (@indiaberry)
 * [19 years ago](https://wordpress.org/support/topic/prevent-google-from-reading-comment/#post-549599)
 * Thank you. I was having a hard time figuring out what went wrong. From now on,
   I will include the closing bracket. Topic solved.

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘Prevent google from reading comment…’ is closed to new replies.

 * 12 replies
 * 4 participants
 * Last reply from: [indiaberry](https://wordpress.org/support/users/indiaberry/)
 * Last activity: [19 years ago](https://wordpress.org/support/topic/prevent-google-from-reading-comment/#post-549599)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
