Skip to content

Instantly share code, notes, and snippets.

@emarthinsen
Created June 9, 2018 22:50
Show Gist options
  • Save emarthinsen/11400c0018e1adc8626b6a5f645724f2 to your computer and use it in GitHub Desktop.
Save emarthinsen/11400c0018e1adc8626b6a5f645724f2 to your computer and use it in GitHub Desktop.
.htaccess - take 3
# Set the REQUIRE_AUTH environment variable if we should password protect
SetEnv NO_AUTH 1
SetEnvIfNoCase HOST staging !NO_AUTH
SetEnvIfNoCase Request_URI ^/privacy-policy$ NO_AUTH
RewriteRule ^ https://www.google.com$%{ENV:NO_AUTH} [L,R=302]
# Define the basic auth setup
AuthType Basic
AuthName "Staging Area"
AuthUserFile /var/app/current/public/.htpasswd
# Allow all access if NO_AUTH or a valid user
<RequireAny>
Require env NO_AUTH
Require valid-user
</RequireAny>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment