Jump to content

trying to redirect based on ip address- but not working??


techexpressinc

Recommended Posts

 

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

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.

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>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.