Password and username to access site

Discussion in 'Site & Server Administration' started by funnygirl, Aug 16, 2008.

  1. #1
    Hi,

    I'm doing some tutoring at uni and I have set-up a site for students to access files. However, I don't want the whole public to access site, so would like a login window, where user has puts in username and password. I have seen this pop-up kind of window that drops down from the top of the browser and then user can add login details. Sorry I can't find a working example off the top of my head.

    How is this put together? Is this something I can switch on with my host or does it involve programming?

    Thanks:D
     
    funnygirl, Aug 16, 2008 IP
  2. Camay123

    Camay123 Well-Known Member

    Messages:
    3,423
    Likes Received:
    86
    Best Answers:
    0
    Trophy Points:
    160
  3. pr0t0n

    pr0t0n Well-Known Member

    Messages:
    243
    Likes Received:
    10
    Best Answers:
    10
    Trophy Points:
    128
    #3
    You need to put two files in the folder you wish to password protect. Those two files are:
    1) .htaccess
    2) .htpasswd

    Your .htacess file should look like this:

    
    AuthUserFile /path/to/your/folder/.htpasswd
    AuthName "Password Protected Zone"
    AuthType Basic
    require valid-user
    
    Code (markup):
    Of course, in example above you need to change that /path/to/your/folder/ to actual path to your folder where you want to place your protected files, OR where you want to place that .htpasswd file (which contains username/password combinations). Note that .htpasswd does not have to be in the same folder which is password protected, just place your correctpath to .htpasswd in your .htaccess file and that's it.

    Your .htpasswd file should look something like this:

    
    username1:crypted_password1
    username2:crypted_password2
    username3:crypted_password3
    
    Code (markup):
    etc. So each Username:password combination goes in new line. Do not lave spaces on the end of line. Password also has to be crypted, you can do this via some site... for example through this site: http://css.psu.edu/publish/htpasswd/htpasswd.html or http://www.htaccesstools.com/htpasswd-generator/ etc. You can use google to search for "htpasswd generator" for other sites.

    I hope this helps.
    Note 1: .htaccess and .htpasswd files need to have that dot (.) on the beginning of the filename.
    Note 2: It may happen after uploading that you won't be able to see those two files, depending on which ftp client are you using to upload. Some ftp clients do not show files beginning with a . (dot) considering such files as hidden. So don't worry about it in that case, just when you want to upload new .htpasswd with new user/pass combinations just re-upload it to that same folder, and old file will be overwritten.
     
    pr0t0n, Aug 16, 2008 IP
    shallowink likes this.
  4. vezycash

    vezycash Peon

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    The htaccess site was useful thanks I never knew that they even existed.
     
    vezycash, Jul 18, 2009 IP
  5. biggunn

    biggunn Active Member

    Messages:
    692
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    70
    #5
    Your web host control panel might have an .htaccess generator...
     
    biggunn, Jul 18, 2009 IP