I have a directory protected by htaccess. Here is the code I use now:
AuthName \"Test Area\"
Require valid-user
AuthUserFile \"/***/.htpasswd\"
AuthType basi
According to this article you can accomplish this by using SetEnvIf
. You match each of the folders and files you want to grand access to and define an environment variable 'allow' for them. Then you add a condition that allows access if this environment variable is present.
You need to add the following directives to your .htaccess.
SetEnvIf Request_URI "(path/to/directory/)$" allow
SetEnvIf Request_URI "(path/to/file\.php)$" allow
Order allow,deny
Allow from env=allow
Satisfy any