1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Password-protecting a folder with a .htaccess
This guide explains how to password-protect a folder by using your site's .htaccess file.
1. Get the full pathway of the directory to be protected
- log in to your hosting using an FTP client or our FTP Manager
- in the folder to be protected, create a file named path.php and copy the following content into it:
- open a web browser and display the path.ph filep (e.g.: votre-domaine.com/dossier_a_proteger/path.php)
- the browser displays the full pathway of the file to be protected. Copy this pathway, we need it for the next step
2. Password selection and encryption
- In the folder to be protected, create a file called password.php and adapt the following content inside it: password of your choice'); ?>
- open a web browser and display the password.php file (e.g.: votre-domaine.com/dossier_a_proteger/password.php)
- the web browser displays your encrypted password. Copy this encrypted password, we will need it in step 4
3. Create .htaccess
In the folder to be protected, create a file called .htaccess and t adapt the following content inside it:
AuthName "Protected administration page"
Replace /example/with the full path copied in step 1 of this guide without path.php at the end. Correct example:
4. Create the .htpasswd file
In the folder to be protected, create a file called htpasswd.txt and adapt the following content inside it:
- Replace login with the login you require
- Replace mot_de_passe_crypté with the encrypted password you copied in Step 2 of this guide
Once the htpasswd.txt file is 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 guide has been followed correctly, the login and password (not encrypted) selected will give access to the protected folder.-->