Skip to content

Instantly share code, notes, and snippets.

@umidjons
Created July 2, 2013 05:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save umidjons/5907025 to your computer and use it in GitHub Desktop.
Save umidjons/5907025 to your computer and use it in GitHub Desktop.
Basic Authentication through .htaccess
# create password for user admin in /etc/httpd/mypasswd file
htpasswd -c /etc/httpd/mypasswd admin
# create .htaccess file in directory that you want restrict access
# write these rules
AuthType Basic
AuthName "Restricted Area"
AuthBasicProvider file
AuthUserFile /etc/httpd/mypasswd
Require valid-user
# these modules should be enabled in httpd.conf
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_default_module modules/mod_authz_default.so
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment