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
  • I am not able to get the password authentication to work on my windows 7 (64 bit).

    —Below is the entry in my .htaccess file:

    AuthUserFile “C:/Program Files (x86)/Apache Software Foundation/Apache2.2/bin/.htpasswd”
    AuthName “Private Network Login Password Required”
    AuthType Basic

    require valid-user

    —————————————————————
    –Below is my entry in the httpd.conf file

    #……………………………………………………….
    #STEP 1. Check for the ACCESSFILENAME directive. On Windows, let us
    # also add the “ht.acl” because although any XP allows me to
    # save a file with “.htaccess” some erlier versions may not
    # allow for it.
    #……………………………………………………….
    AccessFileName .htaccess

    #……………………………………………………….
    #STEP 2. Create a DIRECTORY directive for the directory that you want
    # to password-protect. My e.g., a filed called “SECURE” inside
    # the root apache folder.
    #……………………………………………………….

    AllowOverride All
    Options None
    Order deny,allow

    #####################################
    ~Any assistance is greatly appreciated. Thanks in advance.

  • What error are you receiving

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