It's been a couple of days looking at how I could manage to have different AuthUserFile paths depending on my subdomain.
Why do I have this problem: The admin access of my site is protected by htaccess - htpasswd. I'm now managing the repo with bitbucket and am configuring the automatic deployments. Because of this deployment system, I need to use the same files for every site instance: let's say I have:
local.mysite.com
staging.mysite.com
www.mysite.com
The problem is now that the AuthUserFile absolute path is different for each "site", so I would need to define it based on the subdomains.
What I attempted to do: I was thinking about using If statement like that:
<If "Host == 'local.mysite.com'">
AuthUserFile
</If>
But I'm running apache 2.2 so not available.
I then thought about using something that would look like:
SetEnvIf HOST ^local\.mysite\.com$ ENV_LOCAL
<IfDefine ENV_LOCAL>
AuthType Basic
AuthName "Password required"
AuthUserFile /my/local/path/.htpasswd
Require valid-user
</IfDefine>
But apparently, the IfDefine cannot read the SetEnvIf variables.
And now I'm blocked and can't find anything to help me on internet. I'd be better if I didn't have to change the apache configuration too..
Any ideas?