Sound Internet logo (link to home)

Webmail
2375 University Ave. W. – Suite 210 – St. Paul, Minnesota 55114

Keep in touch with the world.

(612) 617-0007

Services
Support
> Quick Reference 
> Dialup Setup 
> DSL Setup 
> Connection Issues 
> E-Mail Setup 
> E-mail Problems 
> E-Mail Filtering 
> Domain Hosting 
> Newsgroups 
> Shell Access 
Member Tools
About Sound
Searches
Links

Controlling web page access

It is sometimes neccasary to setup a directory within a website to require a username and password; whether it be for a members section or just a directory you want to keep from public access. This is accomplished using two different files. .htaccess and .htpasswd This section will help you setup these files when you want to require this level of security.

.htpasswd

The .htpasswd file stores usernames and passwords. Note the file name is .htpasswd.

To create this file you will need to telnet into the webserver

From any version of windows:

  1. Go to Start and run
  2. Type: telnet superweb or telnet superweb2 depending on what server your site is located on.
  3. When you connect you will be prompted for a username and password.
After you login you will have a prompt similar to this.
user@superweb2:~$

Creating a new .htpasswd file

Now that you are logged into the webserver it's time to create the .htpasswd file.
To create the .htpasswd file you first need to run the command htpasswd along with certain flag,
these flags will specify the password file name, and the username you want to create.

For Example:

user@superweb2:~$ htpasswd -c .htpasswd test
New password: *enter password here. Note you will not see what you type.
Re-type new password: *reenter password. You will not see what is typed.
Adding password for user test

This will create the .htpasswd file. If you were to open this file in a text editor it would look like this

test:Fr4X0tTlgtSBg

To add another user to an existing .htpasswd file you would type in

user@superweb2:~$ htpasswd .htpasswd test2
New password: *enter password here. Note you will not see what you type.
Re-type new password: *reenter password. You will not see what is typed.
Adding password for user test

.htaccess

The .htaccess file is placed in a directory that you want to secure access to. Note the file name is just .htaccess

Creating the .htaccess file

This file can be created with any text editor then uploaded to our servers.
Here's an example .htaccess file

AuthUserFile /home/username/.htpasswd
AuthName EnterPassword
AuthType Basic

require valid-user

The first line is the full server path to the .htpasswd file.
The second line is the "AuthName" that's the name displayed on the area you want to access.
This could say EnterPassword or Restricted or Members Only, etc.
The third like shows we are using basic HTTP Authentication.
The final line shows that a person is required to give a user/pass to get into that directory.
The "valid-user" will allow anyone listed in the .htaccess file in.
If you wanted to specify one user you would put this line in instead.

require user test

Putting it all together

Now that both the .htaccess and the .ht passwd files have been created it's time to put them in the correct places.
The .htaccess file will get placed in the folder you wish to protect access to.
The .htpasswd file should be placed in your home directory.
This directory is not accessable through the web
and therefore people can not download the passwd file.

>Site Map