0

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?

2 Answers 2

1

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

Add:

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

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> 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.