Setting up Apache Authentication with htpasswd / htaccess

Authentication in Apache is done through htaccess, either from the configuration file, or from the .htaccess file in a given directory. Note that only full directories can be easily protected with this method.
Here is how: (first log in to the shell, as this method only works if
you have shell access)

$ cd .../html/protected_dir

$ cat > .htaccess

AuthType Basic

Authname "Protected KLC directory"

AuthUserFile ../../control/htpasswd

AuthGroupFile /dev/null

Require valid-user

+d

$ htpasswd -c ../../control/htpasswd user_name

[give passwd]

After the file is created for the first time, to
add more users:

$ htpasswd ../../control/htpasswd user_name

There are also more sophisticated authentication schemes available, that allow database driven authentication. Feel free to contact me for more information about those solutions.


Do you have an authentication routine, like htpasswd to protect web pages?

Authentication in Apache is done through htaccess, either from the configuration file or from the .htaccess file in a given directory. Note that only full directories can be easily protected with this method.
Here is how: (first log in to the shell, as this method only works if
you have shell access)

  • $ cd …/html/protected_dir
  • $ cat > .htaccess
  • AuthType Basic
  • Authname “Protected KLC directory”
  • AuthUserFile ../../control/htpasswd
  • AuthGroupFile /dev/null
  • Require valid-user
  • +d
  • $ htpasswd -c ../../control/htpasswd user_name
  • [give passwd]

After the file is created for the first time, to
add more users:

$ htpasswd ../../control/htpasswd user_name

There are also more sophisticated authentication schemes available, that allow database-driven authentication. Please contact us for more information about those solutions.