How to Password Protect a Directory

You can protect your web directories by following these steps.

First, log in to the Yolk control panel and go to the file manager. Then, create a text file inside the web/yourweb.com/private/ directory named password.txt.

Go to this website and enter your username and password, then generate the hash. Copy the generated hashed password and paste it into the password.txt file that you created. Rename the password.txt file to .htpasswd .

After completing that, go to web/yourweb.com/public_html/mydirectory, which is the directory you want to protect, then create another text file named file.txt and paste the code below into that file:

AuthType Basic
AuthName "restricted area"
AuthUserFile /home/username/web/yourweb.com/private/.htpasswd
require valid-user

Replace “username” with your panel username and “yourweb.com” with the domain name.

Now, rename the file.txt to .htaccess . When you visit the “mydirectory” directory, it will prompt you for a username and password to access it.

If you have any other questions, please open a support ticket through the client area.