Protect Apache Directories
Updated: 10/21/2003
General Information
In order to password protect a website, or part of a website, we need to create a .htaccess file and a .htpasswd file. These are the files that Apache reads from to see who is allowed in the site. This guide will show you how to setup a website directory with password protection.Requirements
Configuration
| # | nano -w /usr/local/etc/apache/httpd.conf |
|
<Directory "/path/to/protected/directory"> AllowOverride AuthConfig </Directory> |
| # | apachectl restart |
|
# htpasswd -c /path/to/protected/directory/.htpasswd fred New password: Re-type new password: Adding password for user fred |
|
# nano /path/to/protected/directory/.htaccess AuthUserFile /path/to/protected/directory/.htpasswd AuthName "Login Text" AuthType Basic require valid-user |
Author: Jon LaBass
jon at bsdguides dot org