How to Create a Login Web Pageby Katelyn Kelley
A web page requesting a login appears when your web browser hits a directory on a web server that is password protected. The web manager for the site sets up usernames and passwords for the directory with a web site management tool, sometimes referred to as a web control panel, or by creating a file called .htaccess, which lists the authorized users.
Create Login with a Web Control Panel
Navigate with your web browser to your web hosting account and log in to access your control panel. The example shown here is the cPanel X web site management tool.
Click the icon for "Password Protect Directories."
Locate the folder (directory) you want to password protect. Click on a "folder ICON " to go into that folder, click on folder "NAME" to select it as the one to protect.
Click the "check box" at the top to turn protection on, then enter a username and password on the set password screen, and click add/modify authorized user. You can also use this screen to change the password of an existing user or delete a user. Existing users are listed in the order they were added. The list is not alphabetical.
Exit your web host account and navigate to a web page in the directory with the password protection. A login box will prompt you for a username and password.
Enter the appropriate username and password combination, then click "OK." If the login is correct you will have access to the page. If the login is wrong, you will receive an Authorization Required error page.
Create Login with an .htaccess File
Log in to your web hosting account and access the command line level for your web server. This method is only recommended if you understand how to work on your sever at the system level and are familiar with UNIX commands.
Change directories into the folder you want to protect and create a text file there called .htaccess.
Enter the code you see in this figure, substituting the directory path highlighted in yellow with the path to your protected directory (remember the path starts at the root (/) level of your web server) and the username needed to access that directory.
Save the .htaccess file, then at the system prompt from your web server, enter the command: htpasswd -c .htpasswd username, where "username" is the username you put in the .htaccess file. The server will prompt you for a password for this username twice (to verify you entered it correctly).
Enter the password and press Enter/Return. This command creates an encrypted file called .htpasswd in the protected directory that contains the username and password combination you just entered.
Adjust the access privileges for the two files you just created by entering these two commands at the system prompt: chmod 755 .htpasswd, and chmod 755 .htaccess .
User your web browser to test the login.
- check Decide on a standard format for the usernames and passwords on your site, especially if you have a large organization. Inevitably someone will forget how to log in and having a standard set of log in instructions to send out will make troubleshooting easier. If you have a choice between using a web server control panel or creating an .htaccess file for password protection, use the control panel. Basically, the control panel is doing the same thing, but the technical aspects of editing the file are done behind the scenes, and it's easier to add multiple users and update passwords with the control panel.
- close If you decide to go with a shared password instead of individual passwords, be sure to change it at least every six months. Don't attempt the .htaccess method unless you have some familiarity with a UNIX environment and using UNIX commands. Typing the wrong command at the system prompt could have a negative effect your web server.