Here is how to protect a folder with username and password in xampp :
- Open the command promote
- Go to your xampp folder and then go to: /apache/bin/
- Run this command :
htpasswd.exe -c -b .htpasswd my_user _name my_password
Don’t forget Change “my_user_name” and “my_password” - A file with the name of .htpasswd will be created at the folder of /apache/bin
- Create a file with the name of : .htaccess at the folder you want to protect ( don’t forget the dot in .htaccess)
- Write the following in the .htaccess file:
AuthType Basic
AuthName “v3d”
AuthUserFile “c:/xampp/apache/bin/.htpasswd”
require valid-user
Note that the path in AuthUserFile line (c:/xampp/apache/bin/.htpasswd) is the path to your xampp folder where the .htpasswd file is created, very important to keep this file away from the httdocs folder.