Allow access to protected non-drupal directory

Home

Allow access to protected non-drupal dir

In a previous article here we explained how to regain access to your non-drupal created directories by editing the root .htaccess file. When i first came across this issue i thought i could just give access to the protected directory in the same way i did a non protected directory & it would then just prompt me for the username & password when i tries to access the directory that is protected.

This is not the case however, you do need to take the same steps as in the previous article but you also need to take a second step, the second step is to edit the .htaccess within the subdirectory itself, this will have been created when you protected that subdirectory. So copy the subdirectories .htaccess then edit it to contain the following lines which will tell drupal to ignore this directory.

user@something.com [~/public_html/somedir]# vim .htaccess

### the following allows users in to this directory without drupal interfering ###
ErrorDocument 401 "Unauthorized"

AuthType Basic
AuthName "somedir"
AuthUserFile "/home/user/.htpasswds/public_html/somedir/passwd"
require valid-use

 

The line ErrorDocument 401 "Unauthorized" tells drupal to ignore this directory thus allowing apache2 to handle it's permissions again, allowing you to be promoted for a username & password when navigating to this protected directory as previously. The 4 Auth lines are the existing .htaccess so you should only be adding the 1 ErrorDocument line.

When i ran into this problem i found many articles explaining how to regain control of a protected non-drupal directory from fairly simple to so over the top complex they would make your eyes water, this solution is 1 line & about as simple as it gets.