Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

This password protects my site if I visit it like this: www.mydomain.com/index.html but not when I visit it directly like www.mydomain.com.

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

share|improve this question

2 Answers 2

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

    <Directory subdir>
        Allow from all
        Satisfy Any
    </Files>
</Directory>

share|improve this answer

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

Add:

<Location />
Require valid-user
</Location>
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

Your Answer

 
discard

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.