webguync Posted August 17, 2010 Share Posted August 17, 2010 I assume this can be done somehow w/ PHP. How would I create a page which only displays based on detection of certain IP addresses and if the certain IP address is not detected, then redirects to a not allowed page. I have a list of the IP addresses to allow. Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/211000-restricting-a-url-based-on-an-ip-address/ Share on other sites More sharing options...
ober Posted August 17, 2010 Share Posted August 17, 2010 Check the variable $_SERVER['REMOTE_ADDR'] Link to comment https://forums.phpfreaks.com/topic/211000-restricting-a-url-based-on-an-ip-address/#findComment-1100495 Share on other sites More sharing options...
webguync Posted August 17, 2010 Author Share Posted August 17, 2010 ok so once an IP addressed is determined, is it just a matter of an if/then statement to determine whether to allow or to re-direct? I actually have a list of about 30 IP addresses to allow. I guess that is the part I am not sure of how to best handle. Link to comment https://forums.phpfreaks.com/topic/211000-restricting-a-url-based-on-an-ip-address/#findComment-1100499 Share on other sites More sharing options...
ober Posted August 17, 2010 Share Posted August 17, 2010 Put the IPs in an array and loop through them using a foreach() and basically say, if $_SERVER['REMOTE_ADDR'] == $value, do whatever. Link to comment https://forums.phpfreaks.com/topic/211000-restricting-a-url-based-on-an-ip-address/#findComment-1100508 Share on other sites More sharing options...
PFMaBiSmAd Posted August 17, 2010 Share Posted August 17, 2010 in_array Link to comment https://forums.phpfreaks.com/topic/211000-restricting-a-url-based-on-an-ip-address/#findComment-1100513 Share on other sites More sharing options...
webguync Posted August 17, 2010 Author Share Posted August 17, 2010 thanks I will look into In array Link to comment https://forums.phpfreaks.com/topic/211000-restricting-a-url-based-on-an-ip-address/#findComment-1100517 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.