This tutorial will help you protect the directories of your website with the use of a username and a password.
Log into your server on SSH. It is not necessary to be connected with the user "admin" : you can login with the user attached to the concerned virtualhost.
Create a .htaccess file in the directory you want to protect. All sub-directories will be protected as well.
Insert the following content in the file:
AuthUserFile /srv/d_disk/www/mydomain.tld/.htpasswd AuthName "My site" AuthType Basic <Limit GET POST> require valid-user </Limit>
Use the command "vi .htaccess" to edit the file. A Google search will help you find the necessary edit commands for "vi".
In the case of a Gandi AI server, do not forget to replace "d_disk" and "mydomain.tld" by the name of your disk and the domain name to be protected.
Please also replace "My site" by the name of your website :)
Let's create the file with the usernames and passwords authorized to access the protected directories. We need to use the command "htpasswd".
For security reasons, the .htpasswd file is not located in the same directory as .htaccess. If you are not experienced to choose the directory on your own, the best is to follow the example below:
htpasswd -c /srv/d_disk/www/mydomain.tld/.htpasswd robert New password: Re-type new password: Adding password for user robert
The password for the user is then requested. You will also need to confirm it.
Warning:
Usernames are case sensitive: "robert" is different than "Robert".The "-c" parameter only needs to be used for the first added user: it is used to force the creation of the file. To add other users, use the same command, but without the "-c" parameter.
No question on this page and its children.
RSS feed for questions matching this filter (Help)Last modified: 21 Nov 2011 at 06:56 by David P.