1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Password protect a directory

Discussion in 'Apache' started by andre75, Mar 12, 2011.

  1. #1
    I have been at this for hours and nothing seems to work. I have created a subfolder in my Web Directory (this is mac, so the directories are slightly different than linux):

    /Library/WebServer/Documents/subfolder

    that I would like to password protect.
    I am using the stock apache installation that came with my mac (not server)

    I edited httpd.conf and changed:
    AllowOverride none
    to
    AllowOverride AuthConfig
    (also tried AllowOverride all)

    I did this in the
    <Directory />
    </Directory>
    and
    <Directory "/Library/WebServer/Documents">
    </Directory>
    sections

    Then I added this code below the last </Directory>

    <Directory /Library/WebServer/Documents/subfolder>
    AllowOverride AuthConfig
    AuthName "Enter Password"
    AuthType Basic
    AuthUserFile /Users/macuser/.htpasswd
    AuthGroupFile /dev/null
    require user username
    </Directory>

    I created the .htpasswd file:
    htpasswd -bc username password
    and put it in my macuser homedir

    restarted apache
    sude apachectl restart

    and tried it out
    NOTHING

    After a while playing around with this I deleted the
    <Directory /Library/WebServer/Documents/subfolder>
    </Directory>
    section restarted apache and created a .htaccess file in the /Library/WebServer/Documents/subfolder folder with the following contents

    AuthUserFile /Users/macuser/.htpasswd
    AuthGroupFile /dev/null
    AuthName "Access Name Here"
    AuthType Basic

    <Limit GET POST PUT>
    require valid-user
    </Limit>

    Tried it out and again NOTHING

    I tried several variations of the .htaccess file, including an online generator:
    http://cooletips.de/htaccess/index.php
    I also copied the .htpasswd file to the webserver directory itself, but that made no difference either.
    But this thing is stubborn. It won't password protect my folder no matter what I try.

    At this point I am desperately looking for any advise. I hope that someone here knows the answer.
     
    andre75, Mar 12, 2011 IP
  2. Natcoweb

    Natcoweb Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Create .htaccess file with the following contents:

    AuthName "Access Name Here"
    AuthType Basic
    AuthUserFile /Users/macuser/.htpasswd
    require valid-user
     
    Natcoweb, Mar 18, 2011 IP