Sign up ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I need to exclude protection on one of the folder inside a protected directory with .htaccess

I put .htaccess in here:


The directory need to be exclude from protection:


My .htaccess file :

AuthUserFile "/home/mysite/.htpasswds/public_html/new/administrator/passwd"
AuthType Basic
AuthName "admin"
require valid-user
SetEnvIf Request_URI "(/components/com_phocagallery/)$" allow
Order allow,deny
Allow from env=allow
Satisfy any

I tried but not working on my purpose. I suspect my path to the excluded directory may have some mistakes.

share|improve this question

2 Answers 2

As far as I know, this is not possible using plain old .htaccess directory protection. Maybe you can set up a web based authentication and check for each users rights before accessing directories.

The Apache HTTP server also has a lot of mod_auth*-modules, which may help you. See also:

share|improve this answer

Rather than setting environment variables, perhaps you should consider creating a separate set of directives specific to the subdirectory - for example:

.htaccess file:

AuthUserFile "/home/mysite/.htpasswds/public_html/new/administrator/passwd"
AuthType Basic
AuthName "admin"
require valid-user
Satisfy all

public_subdirectory/.htaccess file:

# All access controls and authentication are disabled
# in this directory
Satisfy Any
Allow from all

Directives based upon Apache directives described in How to accomplish “AuthType None” in Apache 2.2 at StackOverflow.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.