Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: redirect 302 help
05-04-2011, 04:42 PM #1
- 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?
Thanks for your help
05-04-2011, 06:43 PM #2
- 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:
<?php $file = $_SERVER['REQUEST_URI']; $file = substr($file, 0, strpos($file,'?')); header('Location: http://'.$ip.$file); exit; ?>
Users who have thanked Wojjie for this post: