Page 1 of 3 123 LastLast
Results 1 to 10 of 26

Thread: Password Protect/.htaccess

  1. #1
    Member
    Join Date
    Apr 2004
    Posts
    91

    Password Protect/.htaccess

    How do I password protect some files/folders so that the random user doesnt download something. I was told .htaccess but I dont know how to use that.

  2. #2
    Banned
    Join Date
    Sep 2004
    Posts
    305
    Using the htpasswd program in your bin folder, create a password file for whatever user you want in a folder named auth in your main Apache folder... then fire up Notepad or whatever and create a ".htaccess" file for whatever directory you want protected (save it in that directory as ".htaccess").

    Code:
    AuthType Basic
    AuthName "Restricted Files"
    AuthUserFile c:/apache_dir/auth/htpasswd
    Require user whatever_user_you_made

    [edit]
    Made some corrections to clear up what I wrote.

  3. #3
    Banned
    Join Date
    Aug 2001
    Location
    Yes
    Posts
    4,424
    Here's a nice little tutorial on how to do it.

  4. #4
    Senior Member
    Join Date
    Nov 2002
    Posts
    186
    Hey phil,
    I hate to be a jerk and just say use Google, but I honestly knew nothing about the .htaccess file until like 10 minutes ago. I read some stuff on the first google link. (check out http://www.javascriptkit.com/howto/htaccess3.shtml )
    Among other things this explains how it is used to set permissions on folders. I think this will get you started. Good luck!
    \"When you say best friends, it means friends forever\" Brand New
    \"Best friends means I pulled the trigger
    Best friends means you get what you deserve\" Taking Back Sunday
    Visit alastairgrant.ca

  5. #5
    Banned
    Join Date
    Sep 2004
    Posts
    305
    Originally posted here by Algaen
    Hey phil,
    I hate to be a jerk and just say use Google, but I honestly knew nothing about the .htaccess file until like 10 minutes ago. I read some stuff on the first google link. (check out http://www.javascriptkit.com/howto/htaccess3.shtml )
    Among other things this explains how it is used to set permissions on folders. I think this will get you started. Good luck!
    Bah, I'll stick up for him... sometimes even finding an article online about you're looking for doesn't help you as much as talking to an actual person... especially when doing it for the first time.... let it go. =\

  6. #6
    Banned
    Join Date
    Sep 2004
    Posts
    305
    Ok, open cmd and do as follows:

    1.) CD into Apache's bin directory.
    2.) Type "htpasswd -c C:\wherever\apache\is\auth\htpasswd user_name"
    3.) Now open Notepad and create a file called ".htaccess" and save it in the directory (htdocs main folder or whatever subdirectory you want) you want to protect with a password. Make sure the ".htaccess" file has the following:

    Code:
    AuthType Basic
    AuthName "Restricted Files"
    AuthUserFile c:/apache_dir/auth/htpasswd
    Require user whatever_user_you_made
    5.) Reload the directory with the .htaccess file and bam! Job done..

    Now I'm going to sleep...

  7. #7
    Member
    Join Date
    Apr 2004
    Posts
    91
    Sorry I just get very pissed off and frustrated when things dont work right, especially when it has to do with computers.

  8. #8
    Banned
    Join Date
    Aug 2001
    Location
    Yes
    Posts
    4,424
    1. Create a file called ".htaccess" (htaccess is the actual file extension... don't give it another one). In that file, place the following information:
    Code:
    AuthName "secured directory"
    AuthUserFile http://yoursite/secured area/.htpasswd
    AuthGroupFile /dev/null
    AuthType Basic
    require valid-user
    Upload the file to the directory you would like to secure (in this case: http://yoursite/secured area/)

    2. Create a file called ".htpasswd":
    Code:
    username:password secured with md5
    Upload it to the same directory.

    And here's a little tool do to the md5-encryption for the password.

    That's basically it. READ that link I gave you for the details.

  9. #9
    Member
    Join Date
    Apr 2004
    Posts
    91
    "/dev/null" I dont use Linux.

    If .htacess is the file extension, what is the file name. Anything?

    Edit: I think I did everything just how you said and it didnt work. I made new text documents and saved them with those extentions, both with the name of admin. (admin.htaccess, admin.htpasswd)

  10. #10
    Banned
    Join Date
    Aug 2001
    Location
    Yes
    Posts
    4,424
    READ the tutorial. The file names are ".htaccess" and ".htpasswd", not SOMETHING.htaccess or SOMETHING.htpasswd.
    And your avatar is a Linux-pengiun

Posting Permissions

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