Skip to content

Instantly share code, notes, and snippets.

@Muminur
Forked from siffring/.htaccess
Created April 13, 2019 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Muminur/31daac79318f3b863f88503c444c9030 to your computer and use it in GitHub Desktop.
Save Muminur/31daac79318f3b863f88503c444c9030 to your computer and use it in GitHub Desktop.
htaccess to password protect a specific server
# ----------------------------------------------------------------------
# Password protect staging server
# Use one .htaccess file across multiple environments
# (e.g. local, dev, staging, production)
# but only password protect a specific environment.
# ----------------------------------------------------------------------
SetEnvIf Host staging.domain.com passreq
AuthType Basic
AuthName "Password Required"
AuthUserFile /full/path/to/.htpasswd
Require valid-user
Order allow,deny
Allow from all
Deny from env=passreq
Satisfy any
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment