1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

php redirect

Discussion in 'PHP' started by leeds1, Dec 31, 2004.

  1. #1
    I want to have links like:

    www. mydomain.com/script.php?loadsoftextandnumbers=url=somethingelse

    and redirect to

    www. anotherdomain.com/loadsoftextandnumbersetc

    so the item in bold is simply appended to the anotherdomain.com

    any ideas for my php script?
     
    leeds1, Dec 31, 2004 IP
  2. TwisterMc

    TwisterMc Mac Guru

    Messages:
    972
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
  3. crazyhorse

    crazyhorse Peon

    Messages:
    1,137
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Well not sure whether this will help but...

    <?
    /////////////////////////////////////////
    // CHANGE IT TO WHERE YOU WANT TO REDIRECT
    $url = "http://www.happynewyear.nl/2005/";
    /////////////////////////////////////////


    header("Location:".$url);
    die;
    ?>


    :D
     
    crazyhorse, Dec 31, 2004 IP
  4. leeds1

    leeds1 Peon

    Messages:
    585
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #4
    thanks for the replies

    how do I get the bolded text into the php code for this :

    www. mydomain.com/script.php?loadsoftextandnumbers=url=somethingelse

    and redirect to

    www. anotherdomain.com/loadsoftextandnumbersetc


    so script.php would read:

    <?php
    header('Location: http://www.anotherdomain.com/xxxxxxx');
    ?>

    where xxxxx equals some command to bring in the bolded text ?

    any ideas ?
     
    leeds1, Dec 31, 2004 IP
  5. exam

    exam Peon

    Messages:
    2,434
    Likes Received:
    120
    Best Answers:
    0
    Trophy Points:
    0
    #5
    here's your link
    www. mydomain.com/script.php?go=http://www.somewhere.com/somepage.html
    heres your script.php
    <?php
         // you probably want to do some error checking on 
         // the variable before using this in real life
         header( "Location: " . $_GET['go'] );  // 302 redirect
         exit;
    ?>
    
    PHP:
     
    exam, Dec 31, 2004 IP
  6. leeds1

    leeds1 Peon

    Messages:
    585
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #6
    thanks exam

    will it still work if I have multiple "=" in my orginal link?

    ie: mydomain.com/script.php?go=afads123=234=dfsdf

    thanks
     
    leeds1, Dec 31, 2004 IP
  7. sarahk

    sarahk iTamer Staff

    Messages:
    28,500
    Likes Received:
    4,460
    Best Answers:
    123
    Trophy Points:
    665
    #7
    do a var_dump() of $_SERVER and look at $_SERVER['REQUEST_URI']

    use that for your redirect and it will have all and any variables. No need to test for them.

    Sarah
     
    sarahk, Jan 1, 2005 IP
  8. goldensea80

    goldensea80 Well-Known Member

    Messages:
    422
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    128
    #8
    This is my solution
    function auto_jump($location)
    {
        echo '<script type="text/javascript">
              location="'.$location.'"</script>';
    }
    
    PHP:
    Of couse a client must enable javascript.
     
    goldensea80, Jan 7, 2005 IP
  9. leeds1

    leeds1 Peon

    Messages:
    585
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #9
    cheers all - got it working now
     
    leeds1, Jan 7, 2005 IP