How to password protect the domain with htaccess

.htaccesspasswordunixwebsite

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?

Best Answer

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

Add:

<Location />
Require valid-user
</Location>