Today I will show you how is easy creating .htaccess and .htpasswd files to secure some websites folders.
Example:
We run apache and our files are located in /var/www/my-apache-files/secret-folder/
And we want to have password access to this /secret-folder/.
There how we do it:
Use Commands:
cd /var/
htpasswd -c .htpasswd username
New password:blablabla
Re-type new password:blablabla
This commands will create .htpasswd file in /var/.htpasswd
Now go to:
cd /var/www/my-apache-files/secret-folder/
Now we creating .htaccess file:
pico .htaccess
paste to file this lines:
Options +Indexes
AuthUserFile /var/.htpasswd
AuthName “SECRET ZONE”
AuthType Basic
<Limit GET POST>
require valid-user
</Limit>
Ctrl+X y
and we done