tags:

views:

81

answers:

1

I only want to password protect one file in a folder. How can I do this with .htaccess?

+1  A: 

Let's say you want to password protect your secret.html file. Just create a .htaccess file in the same folder as the secret file, with the following content (you may need to customize some values according to your config:

<Files secret.html>
AuthName "Login"
AuthType Basic
AuthUserFile /html/username/.htpasswd
require valid-user
</FilesMatch>

You can also use wildcards to filter some file types only. Imagine you want to password protect all zip files:

<FilesMatch "*.zip">
AuthName "Login"
AuthType Basic
AuthUserFile /html/username/.htpasswd
require valid-user
</FilesMatch>
rogeriopvl
Do you now how to do the opposite? That is exclude one or two files from the password protect?
Brian
you need to have some criteria in order to use wildcards. For instance, imagine you want to password protect all .zip files: <FilesMatch "*.zip"> every other file will be unlocked.
rogeriopvl