-
Assume your directory structure is /var/www/dir1/dir2/dir3
-
Now your directory dir1 should be password protected & directory dir3 should be unprotected. So do this follow below mentioned steps.
Steps 1. Create virtualhost for password protected dir
<VirtualHost *:80>
ServerName crucible.crucibletesting.com
DocumentRoot "/var/www/dir1"
<Directory "/var/www/dir1">
Allow from all
AllowOverride All
Options Indexes FollowSymLinks
AuthType Basic
AuthName "password protected area"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
</Directory>
</VirtualHost>
Steps 2. Now add directory tag for unprotected directory in above virtual host
<Directory "/var/www/dir1/dir2/dir3">
# All access controls and authentication are disabled
# in this directory
Order Deny,Allow
Allow from all
Satisfy any
</Directory>
After adding above tag, virtualhost will be look like this.
<VirtualHost *:80>
ServerName crucible.crucibletesting.com
DocumentRoot "/var/www/dir1"
<Directory "/var/www/dir1">
Allow from all
AllowOverride All
Options Indexes FollowSymLinks
AuthType Basic
AuthName "password protected area"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
</Directory>
<Directory "/var/www/dir1/dir2/dir3">
# All access controls and authentication are disabled
# in this directory
Order Deny,Allow
Allow from all
Satisfy any
</Directory>
</VirtualHost>
Great how-to article. Just a small point, order does matter ;-)