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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.