Use .htaccess File for Apache HTTPD Authentication on Windows

Installation of Apache can be found here: Install WAMP (Windows-Apache-MySQL-PHP) with ZIP packages – (5)

Here is a simple example for sharing files to others with authentication by Apache HTTPD on Windows.

Folder to share is D:ToolsApachehtdocsshare

1. Update httpd.conf

In <Directory "D:ToolsApachehtdocs"> session, update "AllowOverride None" to "AllowOverride AuthConfig" or "AllowOverride All".

2. Create password file

Run the following command: (If you have never create such a password file, such as D:ToolsApacheconfpasswd.txt, then use "-c" option.)

D:ToolsApachebinhtpassword -c -b D:ToolsApacheconfpasswd.txt user_for_share passwd_for_share

If the password file exists, use "-c" option will overwrite it.

D:ToolsApachebinhtpassword -b D:ToolsApacheconfpasswd.txt user_for_share2 passwd_for_share2

3. Create .htaccess file


AuthType Basic
AuthName "My Share for Restricted Access"
AuthUserFile D:/Tools/Apache/conf/passwd.txt
Require valid-user

If you wanna require a specific user for "share" folder, then use "Require user user_for_share" insted of "Require valid-user".

4. Test

Restart Apache service, and then open http://localhost/share/. It will require your authentication now.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s