Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to deny all ip addresses but allow one specific ip address in .htaccess. Can someone tell me how I should configure my .htaccess or is it a different file? I have CentOS 5 and Apache.

share|improve this question
<Directory /directory_name>
    Order Deny,Allow
    Deny from all
    Allow from
share|improve this answer
Small note: This won't work in an .htaccess file but only in the main Apache httpd configuration. If you want to use the snipper in an .htaccess file you'll have to drop the <Directory> tags. – joschi May 4 '11 at 19:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.