Apache: Protect a folder by a password, but one file is for public access

Hi,

let us assume you want to protect a whole directory by password and but one file must be readable for public access. This can easily be done by a .htaccess file.

For example: Who want to trotect the folder /var/www/html and only the file public.html should be readable without a password.

Define a username (here “agent”) and create a password file (.htuser)

root@debdevt # htpasswd -c -B /var/www/.htuser agent


  Allow from all
  Satisfy any

AuthName "Only for Agents"
AuthType Basic
AuthUserFile /var/www/.htuser
require user agent

Note:The AuthUserFile must contain the absolute path to the .htuser file.

Michael

Advertisment to support michlstechblog.info

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.