Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    May 2011
    Thanked 0 Times in 0 Posts

    redirect 302 help

    I am trying to get a simple php/jsp that can read an ip address and redirect to it.

    For example: a person has a link: http://subdomain.domain/filename > this needs to go to the ipaddress displayed on this page (http://xx.x.x.x.x/filename ) this page has a value redirect=ipaddress (so the new url would be http:// ip address/filename. The Ip address is the value which is returned from the loadbalancer and can change.

    I would like to use the information on this page which is the redirect="ipaddress". Do i need to do this in php or .htaccess file or a rewrite?

    $var =('http://ipaddress/filename');exit();?>

    Thanks for your help

  • #2
    Regular Coder
    Join Date
    Apr 2011
    Thanked 39 Times in 39 Posts
    You can do either, though I would opt for PHP.

    One thing you need to consider is that someone might use your 'redirect' script to redirect users to another site, for instance from a spam email. If your redirect script gets used heavily, you can get your domain in some blacklists.

    As for redirecting:
    $file = $_SERVER['REQUEST_URI'];
    $file = substr($file, 0, strpos($file,'?'));
    header('Location: http://'.$ip.$file);
    Not sure how you are getting the ip address from.

  • Users who have thanked Wojjie for this post:

    troyw31 (05-05-2011)


    Tags for this Thread

    Posting Permissions

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