Knowledge base

Welcome to Infomaniak Network's support centre, you will find the answers to the most frequently asked questions below.

On our hostings, the .htaccess file creation to protect directories is simplified with an assistant. In the administration console of your domain, go under "TOOLS" > "Protecting directories". You will then get the following page :


(Fig. 1 : Directory protection assistant)


In the user management, click on the "Add" button (see Fig. 1) if you still haven't added your user(s). You will then get a window asking you a "Username" and a "Password", fill in the fields and confirm.


(Fig. 2 : Adding a user)


You will return to the main page (see Fig. 1), where you can create other users as well as user groups in the same way, according to your need. And finally there will be three steps left to follow to protect one of your directories:


(Fig. 3 : Protect a directory)


  1. Choose the directory to protect with a password in the left hand side arborescence. (section "1" in Fig. 3)
  2. Choose the users and/or groups that can have access to the directory using an identifier. (section "2" in Fig. 3)
  3. Then click on the "Confirm" button to apply the protection to the selected directory. (section "3" in Fig. 3)

From then on when you go to this protected directory, you will find a little lock in the arborescence as well as an extra button "UNPROTECT" which allows you to remove the protection of the directory back to its original way.


(Fig. 4 : Unprotect a directory)


Now what will be the consequence of the protection we have just installed on your directory? Well if we browse to this directory address with our Internet browser, the address being http://www.mydomain.com/admin/ in our example, we will get a window requesting a username and a password. And it will be necessary to enter valid information to display this page.


(Fig. 5 : .htaccess password requested)


That's it, it's over, r directory is protected and you can do the same for other directories, with other users or even usergroups.
loading...
Fermer


If this doesn't work and access to the directory is still not blocked, check the following points:
  • in the left column of the PROTECING DIRECTORIES tool, click the folder that is to be protected.
  • Then, on the right, you will see the list of users that you had already created. All the desired users must be selected (i.e. in the negative). To select several at once, use the CTRL key (as shown below).
  • To sum this up, the folder must be selected on the left in the tree and the users, must be selected on the right.
CAUTION

This tool doesn't permit you to protect access to a single page located in a directory and leaving access to other pages in the directory free.
For intermediate functions, please read the Apache documentation, or for example http://www.commentcamarche.net/contents/apache/apacht.php3


The rest of this first chapter is there for information only, stop here if you are only beginning with directory protection: you can create this protection manually by creating a couple of ".htaccess" and ".htpasswd" files, for which you will find the syntax below but the use of the assistant is nonetheless much simpler.

On the following example, the htaccess protection only authorizes the user damien to connect, and we admit that .htpasswd and .htgroup files are in the same directory in the .htaccess file:

Example of content in a .htaccess file
AuthType Basic
AuthName Restricted
Require user damien
AuthUserFile .htpasswd
AuthGroupFile .htgroup
Example of content in a .htpasswd file
 damien:SWw4VYBD9Z8gU
User passwords must be crypted in the .htpasswd file.

For a protection created with the assistant, as we have seen previously, the .htpasswd file is located at the root of your ftp directory in order to be located before the /web directory (and not in the same directory as the .htaccess) for safety reasons.

Link to this answer :
Hosting »  Security  »  All

Online support

Email support