Setup Basic Authentication
Create a .htpasswd file
- htpasswd -c /path/to/.htpasswd username
Add the following lines to the .htaccess file
- AuthType Basic
AuthName “Restricted Area”
AuthUserFile /path/to/.htpasswd
Require valid-user
Ensure the AuthUserFile path matches where you stored the .htpasswd file
If Authentication Isn’t Working
Modify the httpd.conf file to allow .htaccess authentication
- AllowOverride AuthConfig
Restart Apache to apply
- sudo service apache2 restart
Change Username
- htpasswd /path/to/.htpasswd new_username
Change Password
- htpasswd /path/to/.htpasswd username
Remove Username
- htpasswd -D /path/to/.htpasswd username
you can also edit the file, each line is a user
- sudo nano /path/to/.htpasswd