Say you want to deny access to your entire site except when you access it. The following htaccess code does just that. Instead of a Static IP you could also use a hostname, or part of a hostname..


AuthName "Site Administration"
AuthUserFile /web/user/askapache.com/.htpasswd
AuthType basic
Require valid-user
Order deny,allow
Deny from all
Allow from 24.11.54.6
Satisfy Any

More information about this technique can be found in the htaccessElite.com Authentication Forum

Specific posts:

  1. Order, Allow, Deny
  2. Block everyone except 1 IP Address
  3. Deny based on domain name
  4. Deny a Block of IP Addresses
  5. Deny A User based on their IP address
  6. Basic authentication example