Password protect a folder in Apache (XAMPP and Mac OS X)

First you have to create a file with the user and the password to be used with htpasswd:

/Applications/XAMPP/xamppfiles/bin/htpasswd -c /Applications/XAMPP/etc/.htpasswd admin
New password: 
Re-type new password: 
Adding password for user admin

It’s important to place this file in a place not available from the web service thus no one can download that file. Then add a .htaccess file to the folder you want to protect:

vi /Users/user/Documents/Webs/test.local/.htaccess

And add this content:

AuthName "Protected Area"
AuthType Basic
AuthUserFile /Applications/XAMPP/etc/.htpasswd
require valid-user

Reload the Apache server and then when you try to access to that folders URL you will get an auth prompt like this:

Source: Stabeler.

You might also like

Password protect a Location, LocationMatch or VirtualHost in Apache (XAMPP and Mac OS X)
Protecting a Location or VirtualHost in Apache is very similar to protecting a folder as I explained...

Change root password in MySQL
In GNU/Linux:$ sudo mysqld_safe --skip-grant-tables & $ mysql -u root -p #press enter to use a...

Change password for postgres user in PostgreSQL
In order to change the password for the postgres user you should NEVER do this:$ sudo passwd postgresBy...

VNC service start and stop with a script in Mac OS X
Create a file called, for example, startVNC and fill it with:sudo /System/Library/CoreServices/RemoteManagement/

  1. gracias! funciono a la primera

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.