Password protect using htaccess

Create .htaccess file with following

AuthUserFile /home/username/.htpasswd<br></br>
AuthGroupFile /dev/null<br></br>
AuthName “Private Area”<br></br>
AuthType Basic<br></br>
require valid-user```

**create password file :**

`httpasswd -bc /path/to/file username` [ to create a new file ]  
`htpasswd /path/to/file username` [ to change password or create new user]

Find This text in apache config file

`AllowOverride None`

And Make it :

`AllowOverride All`

or in the vhosts config :

<Directory /var/www/html/>     AllowOverride All </Directory>