Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Apache login protection for specific host
### If the server is accessed throught the dev URL example.dev
### User will need to authenticate.
SetEnvIf Host ^example\.dev$ require_auth=true
AuthUserFile /Path/To/.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
### Useful links
#### http://stackoverflow.com/questions/4068975/domain-name-specific-code-blocks-in-htaccess
#### http://stackoverflow.com/questions/14603568/password-protect-a-specific-url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.