Created
January 2, 2015 17:03
-
-
Save msankhala/b9b5e5d13756859e8f03 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# set the "require_auth" var if Host ends with "example2.com" | |
SetEnvIfNoCase Host example2\.com$ require_auth=true | |
# Auth stuff | |
AuthUserFile /var/www/htpasswd | |
AuthName "Password Protected" | |
AuthType Basic | |
# Setup a deny/allow | |
Order Deny,Allow | |
# Deny from everyone | |
Deny from all | |
# except if either of these are satisfied | |
Satisfy any | |
# 1. a valid authenticated user | |
Require valid-user | |
# or 2. the "require_auth" var is NOT set | |
Allow from env=!require_auth | |
#This will make it so authentication is not required unless the host ends with example2.com (e.g. www.example2.com, dev.example2.com, etc). The expression can be tweaked if needed. Any other host will cause the require_auth var not to get set so authentication is not required. If this needs to be the other way around, the last line could be changed to: Allow from env=require_auth, removing the !. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment