jmmille Posted August 3, 2007 Share Posted August 3, 2007 Ok guys, I'm on a college campus so my internal IP is always the same. I run a web radio streaming music and I don't want to have to remember the IP so I'm trying to set me student webspace to redirect to my radio. On campus, everyone has 130.x.x.x ip addresses so I thought I would set it to redirect people on campus and tell the off-campus people to use VPN to get an on campus IP address. Here's what I have so far: <?php $ip = @$REMOTE_ADDR; $ips = explode(".", $ip); if($ips[0] == 130) { header('Location:http://IPaddress:8888'); } else { echo "You are not located on campus. If you wish to listen to streaming music, please use VPN then try again."; } exit; ?> When I try this script, it just stalls saying "waiting on response from server." Any help will be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/63223-php-redirect/ Share on other sites More sharing options...
premiso Posted August 3, 2007 Share Posted August 3, 2007 <?php $ip = $_SERVER['REMOTE_ADDR']; I hope register_globals is off. At any rate try the above for the ip address, it could be register_globals is off but either way you should access the ip using the above. As for why it is saying "Waiting on response" no clue. If you are trying to hit your own server, that may be the issue. You might also try a meta redirect or javascript redirect instead. See if that changes anything. Quote Link to comment https://forums.phpfreaks.com/topic/63223-php-redirect/#findComment-315120 Share on other sites More sharing options...
jmmille Posted August 3, 2007 Author Share Posted August 3, 2007 Thanks for the tip. I changed the $ip variable with no luck. Then I looked into it a little more and campus is currently having server problems. I'm thinking the server I'm hosted on is one of the problem ones. I'll have to try it again in a bit. Thanks guys Quote Link to comment https://forums.phpfreaks.com/topic/63223-php-redirect/#findComment-315128 Share on other sites More sharing options...
Danltn Posted August 4, 2007 Share Posted August 4, 2007 <?php $ip = $_SERVER['REMOTE_ADDR']; $ips = explode(".", $ip); if($ips[0] == 130) { header('Location: http://127.0.0.1:8888'); // Change 127.0.0.1 to the relevant one } else { echo "You are not located on campus. If you wish to listen to streaming music, please use VPN then try again."; } exit; ?> That works fine for me. You could try purchasing a cheap .US/com/net domain, and putting the script on there with the hosting you get. (No more than $10) Quote Link to comment https://forums.phpfreaks.com/topic/63223-php-redirect/#findComment-315455 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.