I am trying to setup HAProxy in a way that when a user goes to example.com, they are 301'ed to www.example.com, while keeping intact the users ability to go to sub1.example.com, sub2.example.com, etc, the rule I have been trying to use on the front end is:
http-request redirect code 301 location www.example.com if {hdr_beg(host) -i example.com}
but when I run sudo haproxy -f /etc/haproxy/haproxy.cfg -c
to validate of my cfg file, I get the output: error detected in frontend 'https-in' while parsing 'http-request redirect' rule : error in condition: no such ACL : '{hdr_beg(host)'.