How restrict the IP access the my website
Moderator: General Moderators
How restrict the IP access the my website
I use the php make static website,but i think to restrict other IP address access my website,please tell me,thanks!
Re: How restrict the IP access the my website
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.
- 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
.htaccess
#Example comment, below is an example of a spammer's IP
deny from 58.247.46.114
Re: How restrict the IP access the my website
And incorporate that with a MySQL table that stores the banned ip's.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.
Re: How restrict the IP access the my website
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.
Re: How restrict the IP access the my website
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