Haproxy redirections with ssl

Hey,
I have a problem configuring haproxy.
I have the following scenario.
I have the site site.com that runs behing haproxy and I want to redirect
http[://]site -> https[://]www[dot]site
http[://]www.site -> https[://]www[dot]site
https[://]site ->https[://]www[dot]site

I have two frontends (one for http and one for https)

in frontend-http I have the following:
redirect scheme https code 301 if { hdr(host) -i www[dot]site } !{ssl_fc}
redirect prefix https://www[dot]site code 301 if { { hdr(host) -i site }

but the https[://]site does not work, all other redirections work correclty.

Thanks for the help

PS: sorry for the weird URLs but I can’t put URLs (I’m a new user)

how about

http-request set-var(txn.host_header) req.hdr(Host),lower
acl not_www var(txn.host_header) -m beg site
http-request redirect code 301 location https://www.%[var(txn.host_header)]%[capture.req.uri] if not_www
redirect scheme https code 301 if !{ssl_fc}

Best

Sascha