techexpressinc Posted September 2, 2009 Share Posted September 2, 2009 Objective is to redirect the website user based on the location. If the user is at the office at a specified ip address, when an icon is clicked they will have access to the employee area. If the user is not at the specified ip address they will get a not access web page. A icon on the home page will be an hyperlink to the following PHP code: ( ipfliper.php) <?php if ($_SERVER['REMOTE_ADDR']=='69.245.218.248') { header('Location: http://www.turnstone.org/employee2/index.html');} else { header('Location: http://www.turnstone.org/notatoffice.html');} exit; ?> Any words of wisdom will be helpful. Thank you Russ @ techexpressinc.com Quote Link to comment https://forums.phpfreaks.com/topic/172778-trying-to-redirect-based-on-ip-address-but-not-working/ Share on other sites More sharing options...
RussellReal Posted September 2, 2009 Share Posted September 2, 2009 what if the office's IP address changes? Quote Link to comment https://forums.phpfreaks.com/topic/172778-trying-to-redirect-based-on-ip-address-but-not-working/#findComment-910661 Share on other sites More sharing options...
techexpressinc Posted September 2, 2009 Author Share Posted September 2, 2009 static ip - if changes we can change the php code Quote Link to comment https://forums.phpfreaks.com/topic/172778-trying-to-redirect-based-on-ip-address-but-not-working/#findComment-910667 Share on other sites More sharing options...
PFMaBiSmAd Posted September 2, 2009 Share Posted September 2, 2009 but not working?? Yes, but what is it doing? Blank page? Stays on the ipfliper.php page? Redirects to the notatoffice.html page? Tell someone what you see in front of you so they can possible help. And, someone can enter the URL of the employee2/index.html page directly and get to it. You would need to use a .htaccess file (assuming Apache web server) to deny access except for the IP address(es) that you want or you would need to make all the pages .php and put code in the top of each one to check the IP and redirect if there is no match. Quote Link to comment https://forums.phpfreaks.com/topic/172778-trying-to-redirect-based-on-ip-address-but-not-working/#findComment-910668 Share on other sites More sharing options...
RussellReal Posted September 2, 2009 Share Posted September 2, 2009 PFM is right, just go with .htaccess Quote Link to comment https://forums.phpfreaks.com/topic/172778-trying-to-redirect-based-on-ip-address-but-not-working/#findComment-910669 Share on other sites More sharing options...
techexpressinc Posted September 2, 2009 Author Share Posted September 2, 2009 I tried the .htaccess updates without success earlier in the year. that is why i was trying this hopefully simplier the access by saving a url is not all super important since it is not top secret info there. To get the current ip i use this Using this on index2.html to get ip. <p><script language="JavaScript"> VIH_BackColor = "palegreen"; VIH_ForeColor = "navy"; VIH_FontPix = "16"; VIH_DisplayFormat = "You are visiting from:<br>IP Address: %%IP%%<br>Host: %%HOST%%"; VIH_DisplayOnPage = "yes"; </script> <script language="JavaScript" src="http://scripts.hashemian.com/js/visitorIPHOST.js.php"></script> Quote Link to comment https://forums.phpfreaks.com/topic/172778-trying-to-redirect-based-on-ip-address-but-not-working/#findComment-910680 Share on other sites More sharing options...
techexpressinc Posted September 4, 2009 Author Share Posted September 4, 2009 my code to identify the ip is at www.turnstone.org/index2.html any ideas of where i am going wrong? Quote Link to comment https://forums.phpfreaks.com/topic/172778-trying-to-redirect-based-on-ip-address-but-not-working/#findComment-912326 Share on other sites More sharing options...
waterssaz Posted September 4, 2009 Share Posted September 4, 2009 will the users at the office go through proxy before accessing your web page? Quote Link to comment https://forums.phpfreaks.com/topic/172778-trying-to-redirect-based-on-ip-address-but-not-working/#findComment-912328 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.