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

How do you redirect people elsewhere that type in your domain? But allow others access?

Discussion in 'Black Hat SEO' started by Craig8, Aug 7, 2013.

  1. Craig8

    Craig8 Newbie

    Joined:
    Jul 22, 2013
    Messages:
    32
    Likes Received:
    1
    I have a private forum. On the domain's index page (ie DOMAIN), I want two things to happen:

    1. For average people just finding it on Google or typing in the domain (i.e. DOMAIN), I'd like to redirect them elsewhere (whether it's an external site or a personal site, but they won't see the private forum).

    2. I have secondary domains (i.e. REDIRECTDOMAIN) that redirect people to the private forum domain (i.e. DOMAIN). I want those redirect domains (i.e. REDIRECTDOMAIN) to offer the users full access of DOMAIN via clicking (but if they type in the DOMAIN, then they'll get redirected elsewhere like people in #1).


    So, in summary, I want people redirected by special domains to have full clicking access of my private forum, but if someone types in the domain index page (DOMAIN), then they'll get redirected elsewhere (not the private forum).

    How would this be done?
     
  2. sm754

    sm754 Registered Member

    Joined:
    Mar 21, 2012
    Messages:
    93
    Likes Received:
    38
    Occupation:
    Farmer
    Location:
    Azerbaijan
    You'd check the HTTP referer and then redirect the user; this is trivial to do in PHP.
    Of course, anyone can fake the referer - this would only be a superficial security measure.
     
    Last edited: Aug 7, 2013
  3. Abstroose

    Abstroose Elite Member

    Joined:
    Nov 20, 2008
    Messages:
    2,097
    Likes Received:
    3,475
    Occupation:
    Thai Boxer
    Location:
    UK
    Home Page:
    Code:
    <?php
    //The URL you are testing if vistiors came from
    $redirectdomain = "http://www.test.com/referrer.html";
    
    //The URL you want to direct other visitors to
    $newURL = "http://www.google.com/";
    
    $ref = $_SERVER['HTTP_REFERER'];
    if($ref != $redirectdomain){
        header('Location: '.$newURL); }
    else { ?>
    <html>Your site HTML goes here</html>
    <?php } ?>
    
    Put this in a PHP file (index.php). Let me know if you need help.