Back to main page!

Knowledgebase Home Knowledgebase Home
Search the Knowledgebase Browse by Category
How do I password-protect my web pages?
User Opinions
No users have voted.

How would you rate this answer?
Helpful
Not helpful
Password protection, also known as "HTTP basic authentication," is a function of your web server. As of this writing, the most common web server by a considerable margin is Apache. You can find a tutorial on authentication, authorization, and access control on the Apache web site.

A simple recipe is given below. This will work only if you have all of the following: (1) shell access via telnet or ssh, (2) access to the htpasswd program, and (3) a web server that is configured to allow this approach. If this example does not work for you, you will need to consult your web server administrator. If you are that person, you should read the much more complete tutorial on the Apache site.

Step One: to find out what your home directory is, log into your shell account via telnet or ssh. Type the command pwd and press enter. This will display your home directory path. If you cannot complete this step, you do not have shell access and you cannot follow this recipe. Consult your server administrator instead.

Step Two: assuming that your web pages are in a directory called html, your home directory is /MY/HOME/DIRECTORY and that you want to password protect a subdirectory called members that already exists, enter these commands to set up password protection for the first time. Please read these commands carefully and do not type them in literally -- you must substitute the user names that you want, as well as the path of your home directory:

htpasswd -c members.pwd firstmembername
Enter a password for 'firstmembername' when you are prompted to do so
cat > html/members/.htaccess
AuthUserFile /MY/HOME/DIRECTORY/members.pwd
AuthName Members
AuthType Basic

require valid-user

Press CONTROL-D at this point

Of course you may also use a text editor such as vi or pico to create the .htaccess file. You may even create it in notepad and upload it by FTP or SCP.

Step Three: later, when you wish to add another account, follow this much simpler recipe. Please note: you do NOT use the -c option when adding another accoPassword protection, also known as "HTTP basic authentication," is a function of your web server. As of this writing, the most common web server by a considerable margin is Apache. You can find a tutorial on authentication, authorization, and access control on the Apache web site.

A simple recipe is given below. This will work only if you have all of the following: (1) shell access via telnet or ssh, (2) access to the htpasswd program, and (3) a web server that is configured to allow this approach. If this example does not work for you, you will need to consult your web server administrator. If you are that person, you should read the much more complete tutorial on the Apache site.

Step One: to find out what your home directory is, log into your shell account via telnet or ssh. Type the command pwd and press enter. This will display your home directory path. If you cannot complete this step, you do not have shell access and you cannot follow this recipe. Consult your server administrator instead.

Step Two: assuming that your web pages are in a directory called html, your home directory is /MY/HOME/DIRECTORY and that you want to password protect a subdirectory called members that already exists, enter these commands to set up password protection for the first time. Please read these commands carefully and do not type them in literally -- you must substitute the user names that you want, as well as the path of your home directory:

htpasswd -c members.pwd firstmembername
Enter a password for 'firstmembername' when you are prompted to do so
cat > html/members/.htaccess
AuthUserFile /MY/HOME/DIRECTORY/members.pwd
AuthName Members
AuthType Basic

require valid-user

Press CONTROL-D at this point

Of course you may also use a text editor such as vi or pico to create the .htaccess file. You may even create it in notepad and upload it by FTP or SCP.

Step Three: later, when you wish to add another account, follow this much simpler recipe. Please note: you do NOT use the -c option when adding another account! -c creates a new password file and deletes your existing accounts.

htpasswd members.pwd newmembername
Enter a password for 'newmembername' when you are prompted to do so

If you receive error messages, reread this recipe very carefully. If you still receive error messages, talk to your server administrator.unt! -c creates a new password file and deletes your existing accounts.

htpasswd members.pwd newmembername
Enter a password for 'newmembername' when you are prompted to do so
If you receive error messages, reread this recipe very carefully. If you still receive error messages, talk to your server administrator.
Visitor Comments
No visitor comments posted. Post a comment
Related Questions
Attachments
No attachments were found.

Home | Web Design | Print Advertisements | Banner Design | Other Services


Copyright © 2003 Digital Arts Group @ FrankGonzalez.com. All Rights Reserved
About Us | Disclaimer | Privacy Policy | Terms of Use | Design Team | Sitemap