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

I want one top level domain to redirect to several websites

Discussion in 'Cloaking and Content Generators' started by GimmeMoney, Jun 7, 2009.

  1. GimmeMoney

    GimmeMoney Regular Member

    Joined:
    Apr 19, 2009
    Messages:
    401
    Likes Received:
    511
    I want one top level domain to redirect my visitors to several websites depending on what site they come from.

    For example:

    If they come from cnn.com, redirect to site1.com
    If they come from astalavista.com, redirect to site2.com

    How can i accomplish this?

    Thanks
     
  2. grazor

    grazor Registered Member

    Joined:
    Apr 14, 2009
    Messages:
    57
    Likes Received:
    19
    there are a few ways to do this, just search google. I found javascript code to do it here h**p://javascript.internet.com/user-details/referrer-redirect.html
     
  3. GimmeMoney

    GimmeMoney Regular Member

    Joined:
    Apr 19, 2009
    Messages:
    401
    Likes Received:
    511
    Sorry guys. I should have been more specific in my first post.
    I don't want visitors to redirect based on what domain they come from. I want them to redirect based on what page they come from.

    Let me show an example:

    If a visitor comes from cnn.com/news, redirect to site1
    If a visitor comes from cnn.com/events, redirect to site2

    I've searched google but only found ways to redirect based on the domain.

    Help appreciated.
     
  4. kamikaza

    kamikaza Regular Member

    Joined:
    Apr 25, 2009
    Messages:
    217
    Likes Received:
    33
    Location:
    RU
    you can use one those free tds scripts, there's a lot of options, you can setup rules for redirections , like based on referrer, country, browser and so on..
     
  5. thedorf

    thedorf Senior Member

    Joined:
    Oct 1, 2008
    Messages:
    1,193
    Likes Received:
    700
    Occupation:
    what? I gotta have a job?
    Location:
    BHW - Where else?
    one way is to parse the refferer url and redirect based off a keyword, I've done it recently

    pm me if you'd like help and this is a paying job

    or google:

    $_SERVER <- to get the url
    php explode string <- to parse the url
    php str_replace <- if you need to get rid of .html and the like
    php redirect <- headers and relocation
     
  6. khan0

    khan0 Registered Member

    Joined:
    Jul 16, 2008
    Messages:
    75
    Likes Received:
    17
    Location:
    Toronto
    PHP:
    <?php
    $refer 
    $_SERVER['HTTP_REFERER'];

    if (
    strpos($refer,"cnn"))
    {
        
    // cnn visitors go to site1.com
        
    header("location: site1.com");
        
    } else if (
    strpos($refer,"astalavista")){

        
    // astalavista visitors go to site2.com
        
    header("location: site2.com");
        
    } else if (
    strpos($refer,"google")) {

        
    // google visitors go to site3.com
        
    header("location: site3.com");
        
    } else {

        
    // everyone else goes to site4.com
        
    header("location: site4.com");
    }
    ?>
     
  7. GimmeMoney

    GimmeMoney Regular Member

    Joined:
    Apr 19, 2009
    Messages:
    401
    Likes Received:
    511
    Thanks guys. I've tried the code you gave me but it didn't work for me. I've also tried the following code:

    PHP:
    <?php $redirectURL = ?3w.yourdomain.com/index.htm?; if (isset($_SERVER[?HTTP_REFERER?]))
    {
    if (
    strpos($_SERVER[?HTTP_REFERER?], ?Diet?) !== false)
    {
    $redirectURL = ?3w.your_diet_affiliate_link.com?;
    }
    else if (
    strpos($_SERVER[?HTTP_REFERER?], ?Dog?) !== false)
    {
    $redirectURL = ?3w.your_dog_training_affiliate_link.com?;
    }
    else if (
    strpos($_SERVER[?HTTP_REFERER?], ?Potty?) !== false)
    {
    $redirectURL = ?3w.your_potty_training_affiliate_link.com?;
    }
    else if (
    strpos($_SERVER[?HTTP_REFERER?], ?Toddler?) !== false)
    {
    $redirectURL = ?3w.your_potty_training_affiliate_link.com?;
    }
    }
     
    ?>
    The code above is supposed to check the refering url for a keyword and redirect based on that. When i come to my site from an url with the word "diet" in it, it doesn't redirect like it's supposed to do. Instead an error shows: Parse error: syntax error, unexpected ':'


    Help appreciated
     
  8. lurnme

    lurnme Regular Member

    Joined:
    Jul 16, 2008
    Messages:
    309
    Likes Received:
    93
    Without testing I would say it's the formatting.

    I didn't test or even think it out, just made few little changes to what you had.

    Code:
    <?php 
    
    $redirectURL = '3w.yourdomain.com/index.htm'; 
    
    if (isset($_SERVER['HTTP_REFERER'])){
    	if (strpos($_SERVER['HTTP_REFERER'], 'Diet') !== false){
    		$redirectURL = '3w.your_diet_affiliate_link.com';}
    	else if (strpos($_SERVER['HTTP_REFERER'], 'Dog') !== false){
    		$redirectURL = '3w.your_dog_training_affiliate_link.com';}
    	else if (strpos($_SERVER['HTTP_REFERER'], 'Potty') !== false){
    		$redirectURL = '3w.your_potty_training_affiliate_link.com';}
    	else if (strpos($_SERVER['HTTP_REFERER'], 'Toddler') !== false){
    		$redirectURL = '3w.your_potty_training_affiliate_link.com';}
    }
     ?>
    
     
    • Thanks Thanks x 1
  9. GimmeMoney

    GimmeMoney Regular Member

    Joined:
    Apr 19, 2009
    Messages:
    401
    Likes Received:
    511

    Thanks I tried your code and the error no longer appears. The code doesn't seem to do anything though. I'm a complete beginner at this so bear with me.