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

This is not the usual request.

I need to protect a domain while keeping the inner files accessible.

So my HTACCESS file at the domain's root FTP folder is as follows:

 AuthType   basic
 AuthName   "Secure"
 AuthUserFile   /path/to/my/password/.ok_pass
 <Files index.html>
 Require    valid-user

This password protects my site if I visit it like this: but not when I visit it directly like

So how do I set a password to the default document in a directory?

share|improve this question

So, you want it to require a password for / and /index.html but not anything else?


<Location />
Require valid-user
share|improve this answer
Its not working, instead returning a 500 Server Internal error. Apparently the syntax is bad. Can we try anything else? – Jarvis Dec 15 '09 at 23:35
You cannot add <Location> directives within .htaccess files – Philip Reynolds Dec 15 '09 at 23:56
Do you have access to the Apache config to set it there (or can you get your webhost to do it)? – rodjek Dec 16 '09 at 0:14

It's an unusual request, but I think you'd have to password-protect the entire root directory and then override that for all the contents. Overriding it lower down to allow everyone could be tricky and it's something I've never done before, but this might work:

<Directory /root/of/your/site>
    Require valid-user

    <Files index.html otherfile.html etc>
        Allow from all
        Satisfy Any

    <Directory subdir>
        Allow from all
        Satisfy Any

share|improve this answer

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.