I will be password protecting /home/droidozo/public_html/wiki

Create a file .htaccess in the same directory:

[/home/droidozo]# cat /home/droidozo/www/wiki/.htaccess
AuthType Basic
AuthName "moodle"
AuthUserFile "/home/droidozo/.htpasswds/public_html/wiki/passwd"
require valid-user

Here, moodle is the name that appears in the pop up where you are prompted for a password.

Now create the folder structure for the directory containing password, which is not accessible on the server by public.

mkdir -p /home/droidozo/.htpasswds/public_html/wiki

Change to this directory, and:

First create the password file, with one user:

htpasswd -c .htpasswd user1

At this point, you will be asked for a password for user user1. A new password file will be created, containing:


The hashed password differs depending on your password.

Create the password file:

cat /home/droidozo/.htpasswds/public_html/wiki/passwd