Home » Htaccess » Allowing Access From 1 static IP and Deny the rest

Allowing Access From 1 static IP and Deny the rest

by Charles Torvalds

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/
AuthType basic
Require valid-user
Order deny,allow
Deny from all
Allow from
Satisfy Any

More information about this technique can be found in the 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


Comments Welcome

Information is freedom. Freedom is non-negotiable. So please feel free to modify, copy, republish, sell, or use anything on this site in any way at any time ;)

My Online Tools

Popular Articles
Hacking and Hackers

The use of "hacker" to mean "security breaker" is a confusion on the part of the mass media. We hackers refuse to recognize that meaning, and continue using the word to mean someone who loves to program, someone who enjoys playful cleverness, or the combination of the two.
-- Richard M. Stallman

It's very simple - you read the protocol and write the code. -Bill Joy


Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution 3.0 License, just credit with a link.
This site is not supported or endorsed by The Apache Software Foundation (ASF). All software and documentation produced by The ASF is licensed. "Apache" is a trademark of The ASF. NCSA HTTPd.
UNIX ® is a registered Trademark of The Open Group. POSIX ® is a registered Trademark of The IEEE.

+Askapache | htaccess file |

Site Map | Contact Webmaster | License and Disclaimer | Terms of Service | @Htaccess

↑ TOPMain