I am trying to replace a server variable in RewriteCondition with php variable.
forexampe :
I have the following string :
$x="RewriteCond %{HTTP_HOST} ^www";
I want to replace %{VAR} with $var==
$x="RewriteCond %{HTTP_HOST} ^www";
preg_replace("/%\{[^}]+)\}/i","$$1==",$x);
The code above is not working, I am getting a warning from php regex parser :
compilation failed, unmatched parentheses at offset at
I tried to escape $ in the replacement with a backslash, but it also didn't solve the issue.
Is there something wrong with the function?
preg_replace("/\%\{[^\}]+\}/i","$$1==",$x)