Stop going to another site using .htaccess or any other way

Discussion in 'PHP' started by zerandib, Jan 5, 2010.

  1. #1
    hello

    I want to do some thing like this;

    Say im having a website called www.mysite.com

    In there , it contains links to another site ;
    Ex: contain a link called "OTHER" to www.othersite.com

    Normally, when you click the link OTHER it will go to this link called othersite.com

    I want to stop this;
    That is, When u click the link "OTHER"; it should NOT go to othersite.com ; instead should redirect to mysite.com

    I guess, this can be done using .htaccess.... Or else are there any other way of doing this
    [should stop the access of the domain othersite.com]

    pls let me know how can i do this using .htaccess
    ??
     
    zerandib, Jan 5, 2010 IP
  2. CoreyPeerFly

    CoreyPeerFly Notable Member Affiliate Manager

    Messages:
    394
    Likes Received:
    24
    Best Answers:
    5
    Trophy Points:
    240
    #2
    How is the link to the other website stored? Is it in a database or on a static file?
     
    CoreyPeerFly, Jan 5, 2010 IP
  3. zerandib

    zerandib Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Its in a static way
    just as a normal website link
     
    zerandib, Jan 5, 2010 IP
  4. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #4
    Can you ellaborate? your description is a bit bleak.

    Is this what you mean (can you confirm, if im right?):

    You want all outgoing links to othersite.com to be replaced with mysite.com?.

    If so you could do this:

    Create a file named out.php with the following code:

    <?php
    
    $url = $_GET['url'];
    
    $url2 = parse_url($url);
    
    if($url2["host"] == "othersite.com"){
    
    header('Location: http://www.mysite.com/');
    
    } else {
    
    header('Location: '.$url.'');
    
    }
    
    ?>
    PHP:

    Then before your links add (the bold):

    <a href="out.php?url=http://www.othersite.com">OTHER</a>
     
    danx10, Jan 6, 2010 IP