This tip explains how to configure an access via htaccess. This allows password secured access to web directories.
We must add the following statement in Web Folders to protect:
<Directory /yourdirectory/web> Options Indexes Includes FollowSymlinks MultiViews AllowOverride AuthConfig Order allow,deny Allow from all </Directory>
The AllowOverride AuthConfig primitives configure Apache to take into account the .htaccess file in the web directory and its subdirectories.
The .htaccess file
With a text editor create a .htaccess file under the directory to be protected, containing the following lines:
AuthUserFile /path/to/.htpasswd AuthName "protected access" AuthType Basic <Limit GET POST> Require valid-user </Limit>
The .htpasswd contains the logins and passwords.
Creatinf the .htpasswd file
To create the file. htpasswd file, simply run the command
# htpasswd -c /path/to/.htpasswd user
The htpasswd command is present in the bin directory of Apache, the -c option creates the file, note that you must specify the user name and password to the application.
The file is created by the command, from there restart Apache.
Thanks to wjaouadi for this tip