Apache .htaccess – Allow / Deny access from certain IPs

Tuesday, March 2, 2010 0:02
Posted in category Unix/Linux, Web

If  your website is under contruction and you want to allow access just to certain IP numbers, placing the following code in the .htaccess  file, in the website root directory, you can block access to everyone except the IP numbers you specify.

order deny,allow
deny from all
allow from 76.33.193.98
allow from 84.23.122.204
allow from 93.34.133.203

If you wish to deny access to specific IPs use the following code:

order allow,deny
deny from 192.168.0.1
deny from 192.168.0.2
allow from all

You can leave a response, or trackback from your own site.

Leave a Reply

Connect with Facebook