Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2011
    Location
    England
    Posts
    23
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Get data from URL and redirect

    I have searched the net and can not seem to find what I want.

    Basically, I want the php file (redirect.php) to redirect to the url specified in the address bar - for example: http://www.mysite.com/redirect.php?u...ww.google.com/ would redirect to: http://www.google.com

    Just like facebooks redirect.php file. Is there ANY way to do this? Please help it is stressing me out!.

  2. #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    17,027
    Thanks
    4
    Thanked 2,668 Times in 2,637 Posts
    Sure you can use:
    PHP Code:
    <?php
    $sRedirectTo 
    = !empty($_GET['url']) ? $_GET['url'] : 'http://yoursite.com/';
    header('Location: ' $sRedirectTo);
    ?>
    Make sure that the url's provided are encoded as well. If you are generating them a raw_urlencode should do the trick. That prevents it from misinterpreting the characters in the querystring as a part of the actual path.

  3. Users who have thanked Fou-Lu for this post:

    camzenxbt (12-18-2012)

  4. #3
    New Coder
    Join Date
    Aug 2011
    Location
    England
    Posts
    23
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Thanks for the reply! Works brilliantly!


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •