Password protect a folder in xampp

Here is how to protect a folder with username and password in xampp :

  1. Open the command promote
  2. Go to your xampp folder and then go to: /apache/bin/
  3. Run this command :

    htpasswd.exe -c -b .htpasswd my_user _name my_password

    Don’t forget Change “my_user_name” and “my_password”
  4. A file with the name of .htpasswd will be created at the folder of /apache/bin
  5. Create a file with the name of : .htaccess at the folder you want to protect ( don’t forget the dot in .htaccess)
  6. 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.

Leave a Reply

Your email address will not be published. Required fields are marked *