Protecting Directories with .htaccess
November 20, 2009
Protecting Directories with .htaccess
Change to the directory you wish to password protect.
Create a file called .htaccess inside that directory:
# touch .htaccess
Now you must create .htpasswd that will hold the username and encrypted
password of users allowed to access the directory.
Create .htpasswd outside of the web root with the following command:
# htpasswd -c /path/to/.htpasswd <username>
# <enter the password for the user>
# <enter the password for the user>
Use your favorite text editor to add the following to .htaccess:
AuthUserFile /path/to/.htpasswd
AuthGroupFile /dev/null
AuthName EnterPassword
AuthType Basic
require valid-user
AuthGroupFile /dev/null
AuthName EnterPassword
AuthType Basic
require valid-user
Edit httpd.conf and change:
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
Options FollowSymLinks
AllowOverride None
</Directory>
to read:
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
Options FollowSymLinks
AllowOverride All
</Directory>
Posted in
content rss