.htpasswd fileThe .htpasswd file stores usernames and encrypted passwords.
Make sure you can login to your web host over ssh.
Once connected over ssh run this command on the server:
htpasswd -c /home/sites/1234568/include/.htpasswd myuser
-c argument creates the file (use only the first time)/home/sites/1234568/include/ with the real path to your include folder or another path outside of your web directory.myuser with the username you wantYou’ll be prompted to enter a password.
Security tips 🔒: Avoid very simple passwords and don't put the .htpasswd file directly in your web directory or any directory that is public.
👉 To add more users later:
htpasswd /home/sites/1234568/include/.htpasswd anotheruser
Login to the May First Control Panel and navigate to the corresponding Web Configuration tab for the website. Edit the web configuration and under show Advanced Settings in the Settings field insert the following text.
<Location /FOLDER-TO-PROTECT>
AuthType Basic
AuthName "username"
AuthUserFile /home/sites/1234568/include/.htpasswd
require valid-user
</Location>
The "/FOLDER-TO-PROTECT" path can be set to just / if you want to protect the entire site. You could also set it to a different path like /subfolder to protect a single subfolder inside your web folder.
AuthType Basic → basic username/password authenticationAuthName → message shown in the login popupAuthUserFile → absolute path to htpasswdRequire valid-user → requires a user defined with the htpasswd command✅ If correct → access granted
❌ If wrong → access denied
🔴 500 Internal Server Error
.htpasswd set in AuthUserFile🔴 Browser doesn’t ask for a password