Apache web server on windows, how to password protect directory

Running Windows 2003 with Apache 2.2, how do I password protect a web directory?

First, open up your httpd.conf file located in your apache\conf directory. In the directory sections, add the following

<Directory “c:/htdocs/foldername-to-secure”>
 AllowOverride All
 Options none
 Order deny,allow
</Directory>

To create the password file, goto a dos prompt, and into the apache’s bin directory.
run the following command

htpasswd -c -b passwd.txt user1 ihatepasswords

the -c creates a new file, -b uses the password from the command line instead of prompting for it.
Now create a .htaccess file in the directory that needs to be secure with the following code.

AuthUserFile “C:/Program Files/Apache Software Foundation/Apache2.2/bin/passwd.txt”
AuthName “SECURE CONTENT REACHED”
AuthType Basic
<Limit GET POST>
require valid-user
</Limit>

Restart apache and you will be all set.




Related posts:

  1. Installing Subversion on Windows
  2. An error has occured on the server. For details, please check the event (application) log on the web server. Unable to retrieve ArcGIS install directory from the registry
  3. Does reverse proxy work with ArcGIS Server 9.3 when using ISA Server?
  4. Windows program crashes as soon as you run it
  5. Citrix Presentation Server 4.5 licensing server won’t accept license

You can follow any responses to this entry through the RSS 2.0 feed.