I'm trying to set a variable on Apache
ENV=DEV if the http host is the dev URL
or
ENV=PRD if the http host is the prd URL
and then use $_SERVER['ENV'] to create some logic branches
So far none of these have worked for me and we do have the setenvif module installed
SetEnvIfNoCase Referer
SetEnvIfNoCase Remote_Host
What's the right way to do this?
Taking a quick look at the documentation:
So, it's certainly possible to make an environment variable conditional on the
Host
header. It looks like you're trying to use either theReferer
orRemote_Host
headers, neither of which is exactly what you want (although in theoryReferer
should contain the value of theHost
header in most cases).Remote_Host
would be the hostname of the client making the request, which is not at all what you want (and in most configurations would simply not be available, since it's typical to have DNS lookups turned off for performance reasons).Try something like this:
But note also that you can simply reference the value of the
Host
header directly in PHP without going through this chicanery;$_SERVER['HTTP_HOST']
will have exactly what you want.