1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

possible to block google bot from single pages?

Discussion in 'Black Hat SEO' started by aussiejack, May 13, 2015.

  1. aussiejack

    aussiejack Regular Member

    Joined:
    Sep 23, 2014
    Messages:
    493
    Likes Received:
    62
    For some reason I want to block google from certain pages on my site. Lets say I have

    domain.com/page1
    domain.com/page2
    domain.com/page3
    .
    .
    .

    Is it possible to block google just from /page1 and redirect to home? If so, how?
     
  2. asap1

    asap1 BANNED BANNED

    Joined:
    Mar 25, 2013
    Messages:
    4,961
    Likes Received:
    3,185
    I believe you can do this if you put some code in the htaccess or robots.txt file but im not sure what the code is.
     
  3. aussiejack

    aussiejack Regular Member

    Joined:
    Sep 23, 2014
    Messages:
    493
    Likes Received:
    62
    must be htaccess. Who cares about robots.txt. But as far as I know htaccess is always "global" for the whole site and cannot be defined for a single page? Anyone know more?
     
  4. bartosimpsonio

    bartosimpsonio Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 21, 2013
    Messages:
    12,495
    Likes Received:
    11,193
    Occupation:
    CHEAP
    Location:
    DATASETS
    Home Page:
    Just add a PHP snippet to that single page.
     
  5. ekapek

    ekapek Jr. VIP Jr. VIP Premium Member

    Joined:
    Aug 2, 2010
    Messages:
    273
    Likes Received:
    48
    Home Page:
    PHP if your site is dynamic just look for header() function and chcecking user agent in headers. Another way is httaccess. You need a little programinning skills to do that
     
  6. Repulsor

    Repulsor Power Member

    Joined:
    Jun 11, 2013
    Messages:
    770
    Likes Received:
    279
    Location:
    PHP Scripting ;)
    Thats wrong. .htaccess has global control for everything in the directory and inside. So it can control single pages as well.

    But the easiest approach would be something like this, to be added on to your header .php, right under your <?php tag.
    This is coming right off my head, do the tinkering needed before use.

    PHP:
    $redirecturl ="http://google.com";
    $urllist = array("url1","url2");
    if(
    in_array("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]",$urllist)==TRUE){
    if(
    strpos($_SERVER ['HTTP_USER_AGENT'],"googlebot")!=FALSE){
        
    header("Location :$redirecturl");
        exit;
    }
    }
    Havent tested. Use full urls in the $urllist.
     
    • Thanks Thanks x 2
  7. aussiejack

    aussiejack Regular Member

    Joined:
    Sep 23, 2014
    Messages:
    493
    Likes Received:
    62
    thanks man. Really like your idea. For some reason I do not want this thing to show up in the source code. The solution should be invisible to competition. Therefore I thought about htaccess. Any idea how I can do that?
     
  8. bartosimpsonio

    bartosimpsonio Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 21, 2013
    Messages:
    12,495
    Likes Received:
    11,193
    Occupation:
    CHEAP
    Location:
    DATASETS
    Home Page:
    The PHP solution given above will not show up on the source code.
     
    • Thanks Thanks x 1
  9. aussiejack

    aussiejack Regular Member

    Joined:
    Sep 23, 2014
    Messages:
    493
    Likes Received:
    62
    looks as I have to learn some coding
     
  10. bartosimpsonio

    bartosimpsonio Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 21, 2013
    Messages:
    12,495
    Likes Received:
    11,193
    Occupation:
    CHEAP
    Location:
    DATASETS
    Home Page:
    Sure helps with black hat methods ;)
     
  11. Repulsor

    Repulsor Power Member

    Joined:
    Jun 11, 2013
    Messages:
    770
    Likes Received:
    279
    Location:
    PHP Scripting ;)
    The code doesnt really show anything at all. It does nothing, doesnt even come up if for the usual visitors. Its triggered only if the useragent has "googlebot" in the string. If thats a yes, it redirects them.

    You have probably mistaken PHP with javascript. If this was a javascript redirection, the code would have been there in the source, no matter if the action is triggered or not. Not for php.
     
    • Thanks Thanks x 1