SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Enthusiast MAC's Avatar
    Join Date
    Feb 2000
    Location
    Somewhere on the heart of Dixie
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is it possible to username and password a page on a website using the .htaccess file.


    ------------------
    Daniel
    Fan of Photoshop, Dreamweaver, and Macs

  2. #2
    SitePoint Member
    Join Date
    Feb 2000
    Location
    Laguna Hills, CA, USA
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Assuming your UNIX box is set up to use .htacecss use the below to protect a directory then move the page to that directory.

    ------HTACCESS-----
    AuthUserFile /home/path/to/.htpasswd
    AuthName "Access"
    AuthType Basic
    <limit GET>
    require user yourusername
    </limit>

    -----HTPASSWD------

    yourusername:yourpassword

    -------------------

    Hope it helps



    ------------------
    Bringing the Internet back to Earth
    Highland Media

  3. #3
    SitePoint Enthusiast MAC's Avatar
    Join Date
    Feb 2000
    Location
    Somewhere on the heart of Dixie
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I must be doing somthing wrong. I have not been able to get it working yet.
    The .htaccess is working in my server. I can put other things in the .htaccess and they work. Currently I am not even getting any authorization message at all.

    I put the code in the directory's .htaccess file. I also created a .htpasswd file and put a test username and password in it.

    Thanks for all your help.

    ------------------
    Daniel
    Fan of Photoshop, Dreamweaver, and Macs

  4. #4
    Hi there! Owen's Avatar
    Join Date
    Jan 2000
    Location
    CA
    Posts
    1,165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yourpassword needs to be encryted...

  5. #5
    Hi there! Owen's Avatar
    Join Date
    Jan 2000
    Location
    CA
    Posts
    1,165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mine is:

    AuthUserFile /www/pbbt/owen/.htpasswd
    AuthGroupFile /dev/null
    AuthName Admin_Only
    AuthType Basic
    <Limit GET>
    require valid-user
    </Limit>

    with .htpassword being:

    owen:q0z95pn5JEXyg

    your sysadmin may give you a program to make it or there is a way at the telnet prompt...

    ------------------
    uDiscuss.com - the most advanced forums on the Internet!

  6. #6
    Destiny Manager Plebius's Avatar
    Join Date
    Nov 1999
    Posts
    682
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    make sure there is no extra line in the .htpasswd file it will accept a blank username and password and grant access if you
    have an empty line.

  7. #7
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    For security reasons you should put your .htpasswd file in your CGI-BIN or some other location that doesn't allow directory listings or direct web access. Putting it where you have it allows hackers easy access and using that they can try to damage your site.

    ------------------
    Wayne Luke
    Internet Media Provider

  8. #8
    SitePoint Member
    Join Date
    Mar 2000
    Location
    waterford, ireland
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you have shell access to your account, you can go to your /etc folder (cd ~/etc) and issue the command:

    htpasswd -c secure.pwd theuser (enter)

    You'll be prompted for a password twice.

    Then create a .htaccess file in the directory you want to create, a sample follows:

    AuthUserFile /etc/secure.pwd
    AuthName "A Password is required for access"
    AuthType Basic
    <Limit GET>
    require user theuser
    </Limit>

    Make sure to put a couple of blank lines after </Limit> to feed unix, and all should now be ok.

    Thats for a single user

    for multi user:

    in ~/etc directory

    httpasswd -c groupsecure.pwd user1

    this creates the password file and puts in user1.

    then
    httpasswd groupsecure.pwd user2
    httpasswd groupsecure.pwd user3
    .....
    etc.

    Then you have to create the group file, which defines the group to have access to the directory.

    The group file is usually stored, like password files, in the ~/etc directory.

    enter the following into the file groupusers.grp

    siteusers: user1 user2 user3

    The corresponding .htaccess looks like this:

    AuthUserFile /etc/groupsecure.pwd
    AuthGroupFile /etc/groupusers.grp
    AuthName "Enter Your Password"
    AuthType Basic
    <Limit GET>
    require group siteusers
    </Limit>

    Hope that helps

  9. #9
    SitePoint Enthusiast MAC's Avatar
    Join Date
    Feb 2000
    Location
    Somewhere on the heart of Dixie
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am getting a 500 Server Error when ever I go to a file in my directory I have attempted to password. Looking in my error logs I see:
    AuthUserFile takes 1-2 arguments

    The .htaccess file looks correct.

    Thanks for your help!

  10. #10
    SitePoint Member
    Join Date
    Mar 2000
    Location
    waterford, ireland
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Post yer .htaccess file for a looksee.

    Do you have shell access?
    if so, have you done the htpasswd stuff?

    rgds

    Alan

  11. #11
    SitePoint Enthusiast MAC's Avatar
    Join Date
    Feb 2000
    Location
    Somewhere on the heart of Dixie
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ---Start .htaccess---
    AuthUserFile /home/virtual/megaclamps.com/data/dealers/pricing/.htpasswd
    AuthGroupFile /dev/null
    AuthName PasswdProtection
    AuthTyp Basic
    <Limit GET>
    require user brains
    </Limit>
    ---end .htaccess---

    ---start .htpasswd---
    brains:2xG1.8sRMeJ4w
    ---end .htpasswd

    The directory I am trying to password is www.megaclamps.com/dealers/pricing

    I do not have shell access.

    Thanks!


    [This message has been edited by MAC (edited March 03, 2000).]

  12. #12
    SitePoint Enthusiast MAC's Avatar
    Join Date
    Feb 2000
    Location
    Somewhere on the heart of Dixie
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks alot Wluke! I will move it.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •