How to add Apache HTTP Authentication with .htaccess file | Cuelogic Blog

Write Following code in .htaccess file and save it into the folder which you want to authonticate.

Change the path (In red) and enter the Folder path which you want to authenticate.

——————————————————————

AuthUserFile /mnt/web/guide/somewhere/somepath/.htpasswd AuthGroupFile /dev/null AuthName "Somewhere.com's Secret Section"

AuthType Basic require valid-user

require valid-user ——————————————————————–

To create an .htpasswd file, login to the server via telnet(Command line) go to the directory you specified in AuthUserFile. In the example, this is /mnt/web/guide/somewhere/somepath. Then use the htpasswd program with the -c switch to create your .htpasswd in the current directory. (as per following)

—————————————-

htpasswd -c .htpasswd username Adding password for username. New password:

password

Re-type new password:

password



—————————————

To delete users, open the .htpasswd file in a text editor and delete the appropriate lines:

Here is more information

The Apache authentication is used when you need to protect your web content from public access. This is basic security and is only recommended when the information is not so vital because either with Basic or Digest authentication (the two methods Apache supports) in both methods the web content is send to the network without encryption. So if you really need all your data to travel encrypted, use SSL.

via:nediam.com.mx