Created
May 8, 2012 15:39
-
-
Save EpocSquadron/2636437 to your computer and use it in GitHub Desktop.
Htaccess snippet for selective simple auth on staging environment.
This file contains hidden or 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
# ############################################################################## | |
# # HTTP AUTH FOR NON-PRODUCTION PUBLIC SITES # | |
# ############################################################################## | |
# Set environment variable based on Host | |
SetEnvIfNoCase Host \.local(:80)?$ APPLICATION_ENV=development | |
SetEnvIfNoCase Host ^(www\.)?stagingaddress\.com(:80)?$ APPLICATION_ENV=staging | |
SetEnvIfNoCase Host ^(www\.)?productionaddress\.com(:80)?$ APPLICATION_ENV=production | |
# Check for staging so we can set DENIABLE_HOST variable | |
SetEnvIf APPLICATION_ENV staging DENIABLE_HOST | |
# Simple auth. | |
AuthName "Restricted Area" | |
AuthType Basic | |
AuthUserFile /server/path/to/.htpasswd | |
AuthGroupFile /dev/null | |
# Set to deny first, then allow everything unless DENIABLE_HOST is set. | |
Order Deny,Allow | |
Satisfy any | |
Deny from all | |
Require valid-user | |
Allow from env=!DENIABLE_HOST |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment