I am trying to use Apache rewrite to turn something like
https://www.example.com/sub/?v1=123&v2=456
into
https://www.example.com/sub/?v1=789&v2=456
i.e. changing v1 to a specific value and keeping v2. In the real case, there are more parameters.
I have
RewriteCond %{QUERY_STRING} (^|&)v1=123&v2=(\d+).*$
RewriteRule ^sub/$ sub/?v1=789&v2=%1 [NE]
which does everything except keep v2. It gets:
https://www.example.com/sub/?v1=789&v2=
It seems like the %1 substitution did not find anything to substitute. But I can't see why not?
And I did try removing the [NE] flag, but that just causes the '&' to be lost, and does not keep the value either.
I tried this at https://htaccess.madewithlove.be/ and on our staging site, and its consistent that the substitution is not happening.