0

Is it possible using SetEnvIf to set a variable to the content of another variable? and if so, how?

For example

SetEnvIf defined_http_conf_var ^(.*)$ has_been_defined=%{defined_http_conf_var}

So the idea is, if inside the apache.conf or httpd conf defined_htaccess_var has been defined, then has_been_defined inside the .htaccess should now contain the value of it?

Note. This is for apache 2.2

anubhava
  • 761,203
  • 64
  • 569
  • 643
owenmelbz
  • 6,180
  • 16
  • 63
  • 113

1 Answers1

3

You can use it like this:

# unconditionally sets defined_htaccess_var=some_value
SetEnvIf Host ^ defined_htaccess_var=some_value

# sets another var has_been_defined=<value of defined_htaccess_var>
SetEnvIf defined_htaccess_var .+ has_been_defined=$0

See more details here

anubhava
  • 761,203
  • 64
  • 569
  • 643
  • Hi, this is almost - but the problem here is that it sets `has_been_defined ` to BLANK if the `defined_htaccess_var ` is missing, the idea is it only sets this if it has a value. – owenmelbz Nov 23 '15 at 17:04
  • ok try updated answer now. `.+` makes sure `defined_htaccess_var` is not empty – anubhava Nov 23 '15 at 17:14