How to exclude subfolder from password protection with .htaccess

How to exclude subfolder from password protection with .htaccess

You sometimes need to password protect a folder or an entire account/website from direct access. That’s easily done with the appropriate .htaccess file in the protected folder plus the mandatory .htpasswd file with the correct user and password combination(s).

AuthName "Protected Area"
Require valid-user
AuthUserFile "../../.htpasswd"
AuthType basic

But what do you do when you want to enable direct access to a subfolder of the protected folder?
Unfortunately, this cannot be handled in the main .htaccess file, however there is a solution.

In the subfolder you wish to open access to, create a .htaccess file with the following content:

Satisfy any

And that’s it.

 

Leave a Reply