.htaccess – Setting Password For Your Web Folder

You can add a .htaccess file to secure your web folder with password protection. Let’s assume the location web folder is /home/ykyuen/public_html

1. Change directory to /home/ykyuen/public_html

  • cd /home/ykyuen/public_html

 

2. Create the password file .htpasswd using the htpasswd command

  • htpasswd -c .htpasswd <username>

* Please refer to the man page for htpasswd usage
 

3. Create the .htaccess file

AuthName "Password Required"
AuthType Basic
AuthUserFile /home/ykyuen/public_html/.htpasswd
require valid-user

 

4. Check it out thru a web browser

        

Done =)

About these ads

One thought on “.htaccess – Setting Password For Your Web Folder”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s