Hi,

I'm running Drupal 5.7.

How do I password protect a directory or file in Drupal.

I created a directory and a html file in that directory in my cPanel.

Then I tried to set up the password protection in my cPanel but it doesn't seem to work.
When I go to that directory/file in my browser, it says the page doesn't exist??

What am I doing wrong? What is proper way to password protect files in Drupal?

Thanks for your help.

Ted

Comments

waynemwyatt’s picture

If your running Apache, this can be done using the .htaccess file. See this page: http://www.addedbytes.com/apache/password-protect-a-directory-with-htacc...

TaoMan’s picture

I'm having the same problem, I have had two directories protected by .htaccess for ages and now that I have Drupal running I can not access those directories, I get a page can not be displayed error just like you.

BTW I'm using 6.6

tananaBrian’s picture

I had the same problem and my server provider people couldn't tell me what was wrong until the ticket got escalated to a senior support person! The problem is the .htaccess file that Drupal installs in its root directory. If you install Drupal into
/public_html then the .htaccess setup provided by the script will mess up all the directories that you used cpanel to password protect. My solution, which you may not prefer, was to uninstall Drupal, restore my original .htaccess and robots.txt files, then reinstall drupal in a subdirectory (./public_html/d in my case.) This gets everything working again (nearly) ...and I'm using a redirect that I set up in cpanel (in the Domains area) to redirect www.domain.com to www.domain.com/d instead. I'm no expert and am still sorting things out ...and I'd like to A) figure out how to access those old, pre-Drupal for me that is, folders, and B) figure out how to password protect directories within the Drupal directory structure so I can relocated old password-protected folders there and can avoid the domain redirect issues. Keep in mind that your .htaccess files apply to the folder that they are located in and all subfolders from there (unless overridden by .htaccess files in the subfolders.)

Brian

m1mic’s picture

You need to add a RewriteCond to your .htaccess to tell it to ignore the folder(s) that you want to use. Please see http://drupal.org/node/47092#comment-1194271.

slosa’s picture