Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How would I require a password for all files except one using .htaccess?

I have a new website I'm working on that the client wants to keep a secret, but at the same time, I want to put an under construction page with some info on it. I would like to have everything except index.html require a user/password--index.html would be available to everyone.

I have the following, but I'm not sure what I need to add:

AuthName "Restricted Area"
AuthType Basic
AuthUserFile /path/to/file/.htpasswd
AuthGroupFile /dev/null
require valid-user

There are too many files and possibly new files to say "for this set of files require a user/password".

I think it has something to do with something similar to:

<Files index.html>
order deny,allow
allow from all
</Files>

But I'm not exactly sure how.

like image 444
Darryl Hein Avatar asked Jan 29 '09 08:01

Darryl Hein


People also ask

How do I password protect just one file?

Use encryption to password protect a folder or a fileRight-click on the item, click Properties, then click Advanced. Check Encrypt contents to secure data. Click OK, then click Apply. Windows then asks if you want to encrypt only the file or its parent folder and all the files within that as well.


1 Answers

AuthName "Restricted Area"
AuthType Basic
AuthUserFile /path/to/file/.htpasswd
AuthGroupFile /dev/null

<Files "*">
Require valid-user
</Files>

<Files "index.html">
Allow from all 
Satisfy any
</Files>
like image 128
empi Avatar answered Oct 20 '22 01:10

empi