tags: apache   archive   business   charity   climbing   comic   communication   database   email   exchange   family   fm2008   hack   hardware   humour   linux   liverpool   microsoft   money   mysql   network   oes   opensource   outlook   php   pictures   process   project   quote   real_life   review   rss   science   security   software   thought   tsm   updates   webdev   website   windows  

.htaccess password protect

Wed, 09 Jan 2008 07:42:15

A 30 second recap on how to protect your site with a username and password using .htaccess

  • Find and run 'htpasswd -c /var/www/html/sec/pass.htpasswd ryan'
  • -c is to create a new file, ryan is the username. You'll be prompted for a password

  • Create a .htaccess in the directory you want to protect and add the following lines:
  • AuthName "Secure Login"
    AuthType Basic
    AuthUserFile "/var/www/html/sec/pass.htpasswd"
    require valid-user

    Here we're saying the user just needs to exist in the file we created earlier, for more detailed setups, use google.

  • Ensure that 'AllowOveride All' is set for the directory in which .htaccess lives, otherwise the config file wont be processed.
  • Cheers
    Ryan Partington