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

Need Help!! --More Advanced PHP Redirect--

Discussion in 'Black Hat SEO' started by hellohellosharp, May 11, 2011.

  1. hellohellosharp

    hellohellosharp Power Member

    Joined:
    Dec 8, 2010
    Messages:
    625
    Likes Received:
    552
    Occupation:
    CEO @ CLEANFILES LLC
    Location:
    USA
    Home Page:
    Okay, after reading "Method To Get One-Way Backlinks" by showboytridin it got me thinking I could maybe advance the script a bit further....

    First of all, here was his script to redirect search engines:

    Code:
    if (preg_match("#(google|slurp@inktomi|yahoo! slurp|msnbot)#si", $_SERVER['HTTP_USER_AGENT'])) {
    
        header("HTTP/1.1 301 Moved Permanently");
        header("Location: http://www.your-main-site.com/");
        exit;
    
    }
    What I want to do is redirect both the search engine and the normal user, but both to different places. So the search engine ends up at point A and the user at point B such as follows:

    Code:
    <?php
    if (preg_match("#(google|slurp@inktomi|yahoo! slurp|msnbot)#si", $_SERVER['HTTP_USER_AGENT'])) {
        header("HTTP/1.1 301 Moved Permanently");
        header("Location: http://www.first-location.com/");
    	exit;
    } else {
        header("HTTP/1.1 301 Moved Permanently");
        header("Location: http://different-location.com/");
    	exit;
    }
    ?>
    Then this got me thinking...wouldn't the script be more efficient if the original IF looked for the users instead? That way ALL bots would be redirected, not just search engines (what I am saying is, the script would be better if it redirected users to one place, and EVERYTHING ELSE to a different place).

    The problem is I don't know how to check if the visitor is a normal user or a bot...the basical outline of the script would be

    Code:
    <?php
    if (preg_match("#(ANY PERSON-NOT A BOT)#si", $_SERVER['HTTP_USER_AGENT'])) {
        header("HTTP/1.1 301 Moved Permanently");
        header("Location: http://www.new-location.com/");
    	exit;
    } else {
        header("HTTP/1.1 301 Moved Permanently");
        header("Location: http://different-location.com/");
    	exit;
    }
    ?>
    What I am asking for is if someone can tell me how to replace that "ANY PERSON-NOT A BOT" string with the code that would actually work.

    Does anyone know how to do this? Any help would be much appreciated:) Thanks everyone!
     
  2. hellohellosharp

    hellohellosharp Power Member

    Joined:
    Dec 8, 2010
    Messages:
    625
    Likes Received:
    552
    Occupation:
    CEO @ CLEANFILES LLC
    Location:
    USA
    Home Page:
    Anyone know how to do this? Or if it's possible?
     
  3. AdGate

    AdGate Jr. VIP Jr. VIP Premium Member

    Joined:
    Feb 23, 2011
    Messages:
    179
    Likes Received:
    37
    Home Page:
    I don't know if this will be more efficient, but to do the opposite you can have the IF statement check for commonly used browsers.

    Here's a rough list: http://whatsmyuseragent.com/CommonUserAgents.asp

    You can probably find a more comprehensive one on google.