HAProxy: Redirect Root Site Root to Subsite
Solution 1:
nlu is almost there, but the is_root
ACL is a little bit off.
Using path_beg
will lead to any and all paths being matched, when really you only want to redirect requests with an empty path.
Try using acl is_root path -i /
instead since it will only match when the path is ONLY /.
acl is_root path -i /
acl is_domain hdr(host) -i www.domain.com
redirect code 301 location http://www.domain.com/subsite if is_domain is_root
Solution 2:
You can check, if it already starts with subsite and use the negated condition in the redirect:
acl is_subdomain path_reg ^/subsite/
acl is_root path_beg -i /
acl is_domain hdr(host) -i www.domain.com
redirect code 301 location http://www.domain.com/subsite if is_domain ! is_subdomain