Web-1 Hosting Logo

Password protecting directories

Sometimes it is necessary to password protect a directory for administrative purposes. You can use htaccess to protect a directory and all it's child directories very easily.

Your hosting plan must include shell access to do this.

First copy the information below into a text file in the directory you wish to protect changing yourusername to your real username and name it .htaccess.

AuthUserFile /users/USERNAME/.htpasswd
AuthName "Secret stuff"
AuthType Basic
require valid-user

Next, log in via SSH and at the prompt type the following command replacing "username" with the username you prefer:

$ /usr/local/bin/htpasswd -c .htpasswd username <HIT ENTER>
New password: <TYPE PASSWORD>
Re-type new password: <TYPE IT AGAIN>

After hitting enter you will be prompted to enter the password for the username and then asked to repeat it.

This will generate an encrypted password file outside of your web space where only the .htaccess file can read it. The "." placed before the file name makes the file "invisible" to web browsers and telnet clients.

To see the file after it's generated you must use the command "ls -a" at the prompt, which means "list -all" allowing you to view hidden files.

Valid XHTML 1.0! Valid CSS!

Web-1 Hosting  

Copyright 2016 - All Rights Reserved

Unless otherwise noted, all materials on this site are protected as the copyrights, trade dress, trademark, and/or other intellectual properties owned by Web-1 Hosting and/or its affiliates. Use of the materials on this site is for informational purposes only for the clients of Web-1 Hosting Mac Hosting