Skip to content

Instantly share code, notes, and snippets.

@fduran
Created February 20, 2012 18:30
Show Gist options
  • Save fduran/1870533 to your computer and use it in GitHub Desktop.
Save fduran/1870533 to your computer and use it in GitHub Desktop.
Apache password protect directory
# www.fduran.com
# apache password protect directory
# Apache config
<Directory /home/user/public_html>
AllowOverride AuthConfig
# ...
</Directory>
Alias /protected "/home/user/public_html/protected"
<Location "/protected/">
SetHandler None
Options -Indexes +FollowSymLinks
allow from all
</Location>
# auth_* modules needed
a2enmod auth_basic
# passwd file, outside directory served
htpasswd -c /home/user/.htpasswd myuser
# /home/user/public_html/protected/.htaccess file
AuthType Basic
require user myuser
AuthName 'Protected'
AuthUserFile /home/user/.htpasswd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment