HAProxy transparently rewrite path

Good day,

I have one frontend example.com and backend server1. Backend has an application: /app, the application is generating random user tokens to identify them in the application itself, so after entering example.com/app the user gets something like this: example.com/app/(S(829b8293-362f-0554-bc8e-2a84645a2b13)) this is how it looks:

acl host_example hdr(host) -i example.com

use_backend server1 if host_example

backend server1
        mode http
        server web 1.1.1:80 no-check-ssl verify none check

Every thing is working fine, then, i get a second backend with the same app, behavior and told to use the same frontend. Since the second backend is a testing environment i am told to use path /test to distinguish both environments, but the application on the backend is using /app, so, now when i enter example.com/test i need to receive example.com/test/(S(8201k293-362f-0554-bc8e-2a840k144313)) on the users end, since i am not a HAProxy savvy i did some googling and as far as i understood from one article with similar issues - i need to do http-request replace-value Location and http-response replace-value Location. I have tried to make use of that article for my case, but, i did not accomplish anything, i am 100% positive that everything is wrong but i cant figure out what exactly to correct.

acl host_example hdr(host) -i example.com
acl is_test path_beg -i /test

use_backend server1 if host_example
use_backend server2 if host_example is_test

backend server1
        mode http
        server web 1.1.1.1:80 no-check-ssl verify none check

backend server2
        mode http
        http-request replace-value Location /app /test\1
        http-response replace-value Location /test /app\1
        server test 2.2.2.2:80 no-check-ssl verify none check

Best regards,
Nick