Is it possible to password protect 3 files(not directory) with diferrent .htaccess

Discussion in 'Apache' started by lochan, May 2, 2011.

  1. #1
    Hi everyone,

    I am using .htaccess and .htpasswd to password protect a file within a directory. According to my need, i need to password protect 3 different pdf files with individual username and password inside the same directory. Is this possible in apache? I know we can protect an entire directory using <Directory> or a single file using .htaccess file.
    Any suggestion on this issue would be greatly appreciated.

    Thank you
    Lochan
     
    lochan, May 2, 2011 IP
  2. lochan

    lochan Peon

    Messages:
    3
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I was in great need and nobody did answer.
    Anyways I figured it out myself.
     
    lochan, May 3, 2011 IP
  3. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #3
    Just out of curiosity, did you end up using the <Files> container ?
     
    joebert, May 5, 2011 IP
  4. lochan

    lochan Peon

    Messages:
    3
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yes Joebert,

    I used a single .htpasswd file containing <username:encryptedPassword> list like:
    .htpasswd
    user1:HASHA
    user2:HASHB
    user3:HASHC

    and a .htaccess file containing

    AuthUserFile /home/lochan/.htpasswd
    AuthType Basic
    AuthName "My Secret Page"

    <Files "First File">
    require user user1
    require user user2
    </Files>

    <Files "Second File">
    require user user2
    require user user3
    </Files>

    .......
    .......

    That solved my problem.
     
    lochan, May 6, 2011 IP
    hans likes this.