Removing trailing slash and redirect to non-slash

This is my configuration from haproxy.cfg

acl test-service path_beg /test

use_backend test-service if test-service

backend test-service
reqrep ^([^\ ])\ /test(.) \1\ /\2
balance roundrobin
server manager01 127.0.0.1:7081

I want to remove trailing slash from my api url and also redirect all request to non-slash

Deserved api url:
blabla.com/test/abcd or
blabla.com/test

Could you help me about it?
Best regards,

Either you want to rewrite it (so that the browser/client uses the same URL), but only the servers sees it without the trailing slash, OR you would like to emit a redirect without the trailing URL.

You cannot do both. So which is it?

I would like the servers sees it without the trailing slash.

Also I do not want to return any response if my api get “/test/” request. I only want to return a result “/test”(without backlash) requests. How can I achieve that?

Would you like haproxy to send back an error code, like 403 Forbidden? Or would you like to send a redirect?