My hosting has multiple deployments of my site (dev, stage, production). How can I add HTTP Auth headers in my htaccess file if and only if the enviornment variable that they set is equal to ‘dev’? (meaning they set a variable called SITE_ENVIRONMENT that can be dev, stage, or prod depending on which site you’re accessing.
PS. I’m familiar with requiring authorization from htaccess in vanilla ways, but I’m totally lost when it comes to evaluating variables or writing a block based on the outcome.
I’m not sure this is possible.
Theoreticaly, you can use:
to determine which environment you’re in, but I can’t think of how to write the RewriteRule to force a basic auth… unless you redirected to another page which handles the basic auth and resets the SITE_ENVIRONMENT variable to “dev-authenticated” or something.