Skip to content

Instantly share code, notes, and snippets.

@marceloxp
Last active August 29, 2015 14:16
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 marceloxp/08428147b980ab4ac188 to your computer and use it in GitHub Desktop.
Save marceloxp/08428147b980ab4ac188 to your computer and use it in GitHub Desktop.
Apache conditional .htpasswd
SetEnvIf Host .*local.yetanothersite.* VAR_LOCAL_SITE
SetEnvIf Host .*yetanothersitehomolog.com.br.* VAR_HOMOLOG_SITE
SetEnvIf Host .*www.yetanothersite.com.br.* VAR_PROD_SITE
Order Deny,Allow
AuthUserFile /var/../.htpasswd
AuthName "Authorized personnel only."
AuthType Basic
Require valid-user
Allow from env=VAR_LOCAL_SITE
Allow from env=VAR_HOMOLOG_SITE
Deny from all
Satisfy any
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment