Knowledge base
1000 FAQs, 500 tutorials and instructional videos. Here, there are only solutions!
Secure web access with a password
This guide explains how to protect a section of a website on a Web Hosting plan by requiring a password to be entered before a directory (including subdirectories) can be accessed from a browser.
Please note that this does not prevent a user from accessing the directory via FTP.
Simple method
To password-protect (Digest authentication) a directory using the "Folder Protection" tool:
- Click here to access the management of your website on the Infomaniak Manager (need help?).
- Click directly on the name assigned to the website in question:

- Click on Security in the left-hand menu.
- Click on Folder Protection.
- Click on the directory you want to protect.
- Enable protection using the toggle switch, then create one or more users:

- * Users are defined per directory; the tool does not allow you to manage user groups:

- * Users are defined per directory; the tool does not allow you to manage user groups:
- Click the Add button.
- Click the button to Add access for an additional user if needed.
- Click on the action menu ⋮ located to the right of the user you want to modify or remove.
- Click on the toggle switch again to completely disable directory protection:

Manual method via .htaccess
To protect a folder with a password using the .htaccess file of your site:
- Connect to your hosting via an FTP software/client or Web FTP.
In the folder you want to protect, create a file called
password.phpand adapt the following content by replacing12345with the desired password:<?php $password = "12345"; echo password_hash($password, PASSWORD_DEFAULT); // Displays the hashed password ?>- Open a web browser and display the
password.phpfile (example: domain.xyz/folder-to-protect/password.php). - The web browser will display your encrypted password; copy the encrypted password, as you will need it later…
In the folder you want to protect, create a file called .htaccess and adapt the following content within it:
AuthName "Protected Administration Page"
AuthType Basic
AuthUserFile "/example/.htpasswd"
Require valid-userReplace /example/ with the absolute path of the folder you want to protect. Example:
AuthUserFile "/home/clients/0f83c7afb710e5ae2645a1b704d8772f/web/protected_folder/.htpasswd"In the folder you want to protect, create a file called htpasswd.txt and adapt the following content within it:
username:hashed_password- Replace
usernamewith the desired login. - Replace
hashed_passwordwith the encrypted password copied in step 1 of this guide.
Once the htpasswd.txt file has been saved, rename it as follows: .htpasswd.
Open a web browser and try to display one of the pages contained in the protected folder. If the instructions have been followed correctly, the login and password (not encrypted) you chose will allow you to access the protected folder.
Other restrictions may also be applied via .htaccess.
Link to this FAQ: https://faq.infomaniak.com/68
Has this FAQ been helpful?