It's %{} not ${} for variables in RewriteCond's.
Use php_value for values, not php_flag - dunce.
Cannot set empty strings, so comment out for now.