Jump to content

htaccess anyone need help urgent


Recommended Posts


I'm glad it worked out!!!!!

Regardless, for anyone interested in htaccess, here is a tutorial written by one of my friends over at jhu.edu (Lev, teaching assistant for 600.113)

Notes:

it uses the fact that you telnet into a unix account

so unix familiarity needed.

If you need more help.. post and I'll try to help!

By using htaccess, we can restrict access to our sites. We can create usernames and give them specific passwords. In this tutorial, we'll create a file and password protect it.

Note: do NOT password protect your root directory or your public_html or your internet or your project directories or we will not be able to view your hw or projects! The rest of your homeworks will just be zeroes!

Telnet into your JHUNIX account and enter your public_html/internet directory

Create a directory called "secret" and give it rx permissions

Cd into this directory and pico a file called secret.txt

Type a sentence that says "This is a secret", exit, save, and grant permissions.

Now we'll password protect it. By adding HTAccess in this directory, we will restrict access to any file or directory within it.

You are in your secret directory. Type pwd. Highlight the output and copy it.

Mine looks like this:

/users/as/ins/1/.lbh1/public_html/internet/secret

Yours will be different! Do not just cut and paste the example.

Pico .htaccess

This is what goes in your .htaccess file:

AuthUserFile /users/as/ins/1/.lbh1/public_html/internet/secret/.htpasswd

AuthGroupFile /dev/null

AuthName "Enter your password"

AuthType Basic

<Limit GET POST>

require valid-user

</Limit>

AuthUserFile tells us where the .htpasswd file is. It's in the secret directory of our account. The value will be the pathway you highlighted and copied when you did pwd a few minutes ago.

The AuthName is what shows up on the box, instructing or welcoming the user. Now we have created our .htaccess file. What we'll do now is create user names and their corresponding passwords

Save the file and exit.

Type "htpasswd -c .htpasswd username" where username is the username you want.

The first htpasswd is a command (Note that this is htpasswd, and NOT htpassword). We'll execute the command htpasswd which is like a program.

The -c means create. This is only needed the first time.

The .htpasswd is a destination (it'll always be .htpasswd)

It will then say, "Adding password for username. New password:"

This is where you type in a password. It'll ask you to retype it, do that.

Remember the user and password. At least for the next 10 minutes.

Now you created a password for your secret file.

Do it again. This time you won't need a -c since we won't create a file, we'll just add to it.

htpasswd .htpasswd lev

This'll create a new password for lev. Create at least two users and passwords (remember them!)

Now give rx permissions to the .htaccess and .htpasswd files. If you don't, HTAccess won't work.

Bring up the page http://jhunix.hcf.jhu.edu/~login/internet/secret/secret.txt

Give it the password and see what you wrote.

Say you want to revoke password privileges for lev.

Pico your .htpasswd file.

You'll see at least two lines. Each line is a user:password (the passwords are encrypted).

Delete the line with lev. Now he is no longer a user.

That's all there is to password protecting your directories. Remember that usernames and passwords are case sensitive.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...