How restrict the IP access the my website

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
lengyun
Forum Newbie
Posts: 1
Joined: Thu Feb 19, 2009 9:26 pm

How restrict the IP access the my website

Post by lengyun »

I use the php make static website,but i think to restrict other IP address access my website,please tell me,thanks!
vmmene
Forum Newbie
Posts: 8
Joined: Mon Feb 09, 2009 3:26 am

Re: How restrict the IP access the my website

Post by vmmene »

use the $_SERVER['REMOTE_ADDR'] to capture the ip and check the ip's if u want allow the ip the redirect to your site othere wise block that ip.
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: How restrict the IP access the my website

Post by JAB Creations »

.htaccess
#Example comment, below is an example of a spammer's IP
deny from 58.247.46.114
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: How restrict the IP access the my website

Post by papa »

vmmene wrote:use the $_SERVER['REMOTE_ADDR'] to capture the ip and check the ip's if u want allow the ip the redirect to your site othere wise block that ip.
And incorporate that with a MySQL table that stores the banned ip's.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: How restrict the IP access the my website

Post by pickle »

Note that IPs can be spoofed, so you can't rely on the IP 100% to restrict access.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: How restrict the IP access the my website

Post by josh »

Yes IP can be spoofed, but response cannot be read, so a way to circumvent that would be to utilize a javascript redirect to a secret page. If attacker cannot read response he cannot know the secret key. This probably isn't practical for front-ends. but should be employed on requests like POSTing to the admin panel
Post Reply