How to resolve unexpected T_STR_BEGIN regex error in Apache HTTP config?

Viewed 87

I'm trying to add secure flag for session cookies via Apache HTTP Server. The code is working but when I try to wrap it in an IF clause to run this code when HOST is from acstest.com, the code is not compiling. There is a syntax error when I run apacheclt -t

  <If "%{HTTP_HOST} =~ '\.acstest\.com'">
      Header edit Set-Cookie ^ACIJSESSIONID=(.*)$ "CHIJSESSIONID=$1; Secure; SameSite=None"
      Header edit Set-Cookie ^JSESSIONID=(.*)$ "JSESSIONID=$1; Secure; SameSite=None"
  </If>

The error is

Cannot parse condition clause: syntax error, unexpected T_STR_BEGIN, expecting T_REGEX or T_REGEX_I

I'm unable to diagnose the error message.

0 Answers
Related