Skip to content

Instantly share code, notes, and snippets.

@dineshrabara
Forked from siffring/.htaccess
Last active August 29, 2015 14:21
Show Gist options
  • Select an option

  • Save dineshrabara/3e7d024d95fccea2ce72 to your computer and use it in GitHub Desktop.

Select an option

Save dineshrabara/3e7d024d95fccea2ce72 to your computer and use it in GitHub Desktop.
# ----------------------------------------------------------------------
# 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