Strip all expressions after domain name and redirect to domain only

Hi, I have the following currently to redirect all traffic from domain.com to newdomain.com

acl host_redir_domain_com hdr(Host) -i domain.com
redirect prefix https://www.newdomain.com code 301 if host_redir_domain_com

This does the redirect just fine but if I pass the url in my browser domain.com/anyvar then it also redirects to newdomain.com/anyvar which does not exist in the new domain. I want anything after the / to be stripped away and only redirect to the new root domain (ie: newdomain.com only)

Could anyone please help me in achieving this. Your help is much appreciated.
Regards

(HA-Proxy version 1.5.18)

Hi,

I figured it out now, you can use the ‘location’ directive to pass on to the exact location. ie:

http-request redirect location https://www.newdomain.com code 301

as simple as that. Thanx