thank you @bluepuma77 . Updated the original description. I agree that the running version is very old. However I'm trying to resolve this intermittent issue first as this is impacting the application.
but I'm not really sure if that fits to my use case? apologies if I did miss anything.
regex would match with any host.
So if I test the regex expression that I mentioned in my initial post, I can see that the regex is correctly replacing the host, but when this is in live, I sometimes see the redirection is not working as expected.