Skip to content

Instantly share code, notes, and snippets.

@cafuego
Created March 27, 2013 03:45
Show Gist options
  • Save cafuego/5251442 to your computer and use it in GitHub Desktop.
Save cafuego/5251442 to your computer and use it in GitHub Desktop.
conditional auth_basic based on hostname
# Set password authentication on nominated hostname via the
# setenvif module.
<IfModule mod_setenvif.c>
AuthType Basic
AuthName "Enter a damn password you monkey"
AuthUserFile /some/htpasswd
Require valid-user
SetEnvIf Host .*\.example\.com$ NEED_AUTH
SetEnvIf Host .*\.example2\.com$ NEED_AUTH
SetEnvIf Request_URI ^/special/public-path/ !NEED_AUTH
Order Allow,Deny
Allow from all
Deny from env=NEED_AUTH
Satisfy any
</Ifmodule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment