Reputation: 42
Adding this to an older system and am trying to do it in the .htaccess file.
# Prevent search engine indexing on dev sites:
SetEnvIf Host myliveserver\.com$ isproduction
Header set X-Robots-Tag "noindex, nofollow, noarchive" env!=isproduction
Running on Apache 2.2.22 with mod_setenvif
Getting a dreaded 500.
If I remove the conditional env!=isproduction
it runs.
What am I missing about the conditional clause?
Upvotes: -1
Views: 1113
Reputation: 74088
There are two possibilities for a 500
status code
Header
Syntax: Header [condition] set|append|merge|add|unset|echo|edit header [value] [replacement] [early|env=[!]variable]
...
env=[!]varname
The directive is applied if and only if the environment variable varname exists. A ! in front of varname reverses the test, so the directive applies only if varname is unset.
So, your header directive should be
Header set ... env=!isproduction
Upvotes: 3
Reputation: 42
Ah.. there it is...
=!
vs !=
The NOT is applied to the variable, not the equality.
Upvotes: -1