Allowing Access From 1 static IP and Deny the rest

FREE THOUGHT · FREE SOFTWARE · FREE WORLD

Allowing Access From 1 static IP and Deny the rest

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 /home/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


»

Leave your own comment

Reader Comments

  1. Pawel ~

    Hi, regarding the actual htaccess file, where would I save this file on my web server? Do I give the file the extension “.htaccess“?

    Thank you
    Pawel

Go for it!


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

HTML | DCMI | GRDDL | XOXO | XDMP | XFN | DOM | XML | XHTML 1.1 Strict | CSS 2.1 | W3C

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.

Site Map | Contact Webmaster | Glossary | License and Disclaimer | Terms of Service

↑ TOP
Main