Hosting
How I can restrict the access to directories by means of .htaccess?
In order to restrict the access to directories by means of the file .htaccess you must create a file as the following one:
AuthName “Gives your data me�
AuthType BASIC
AuthUserFile /var/www/vhost/tudominio.com/home/data/.htpasswd
AuthGroupFile /dev/null
require to valid-user
Where it puts tudominio.com you will have to put the name of your domain. You must leave the file that you have created in the directory who interests to you to protect.
It is very important that you do not let to spaces nor unnecessary jumps of line at the end of each line, since this type of programming is very sensible and, find this data type, can block the visualization to you of the folder by Web giving you an error 500.
Later you must create a file .htpasswd that you must leave in the /data directory of your website. The file must contain the same information that in this example: user: 15C2CgZErmh1U
The file has a line by each user of access and his password corresponding encriptada, separated by the character two points “: �.
In the example the password (hello) but is encriptada (15C2CgZErmh1U) obtained with the function crypt () of PHP.
For more information, it visits the following pages of the Web of Apache:
http://httpd.apache.org/docs-2.0/es/howto/htaccess.html
http://httpd.apache.org/docs-2.0/es/howto/auth.html
To return to FAQs