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 have searched SO and ServerFault for an hour trying to find the answer, but was unable to. I am sure similar questions have been asked, but here is what I am trying to do:

I just want the site root to be public, and any other url to be password protected. I already have a passwd file ready and working. So, works but would require a password. I cannot do this file-based, because I am running a WSGI application, not an actual index.html. And please specify if the directives should go into a .htaccess or the server's httpd.conf.


Answer: Based on Shane's response, here is the config in my httpd.conf:

<Directory *>
AuthUserFile /path/to/.htpasswd
AuthGroupFile /dev/null
AuthName "Password Protected Area"
AuthType Basic
AllowOverride All

<LocationMatch "/.+">
Require valid-user

Just in case anyone comes across the page and doesn't have that first information.

share|improve this question
up vote 0 down vote accepted
<LocationMatch "/.+">
    Require valid-user

Anything with one or more characters after the slash will get hit with the Require statement; you'll need to remove your current Require but leave the rest of your password config in place.

It should go in the site config, be it httpd.conf or a VirtualHost file.

share|improve this answer
That worked, thanks! – jcady Apr 6 '11 at 17:30

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.