Sunday, May 20, 2012

How to remove .htaccess password protection from a subdirectory


I have password protected my entire website using .htaccess but I would like to expose one of the sub directories so that it can be viewed without a password.



How can I disable htaccess password protection for a sub directory? Specifically what is the .htaccess syntax.



Here is my .htaccess file that is placed in the root of my ftp



AuthName "Site Administratrion"
AuthUserFile /dir/.htpasswd
AuthGroupFile /dev/null

AuthName secure
AuthType Basic
require user username1
order allow,deny
allow from all

Source: Tips4all

3 comments:

  1. You need to create a new .htaccess in the concerned directory and include "Satisfy Any" directive to it.

    ReplyDelete
  2. You need to add another .htaccess file to the subdirectory that overrides the authentication. .htaccess cascades upwards, i.e. it will look in the current folder, then go up a level and so on.

    ReplyDelete
  3. Adding to RageZ's answer, I used this in the Server Directives:

    <Directory /var/www/protected/>
    AuthType Basic
    AuthName "Production"
    AuthUserFile /path/to/.htpasswd
    Require valid-user
    </Directory>

    <Directory /var/www/protected/unprotected>
    Satisfy Any
    </Directory>


    Awesome. Thanks RageZ!

    ReplyDelete