HAProxy:redirect根站点根到子网站

我想默认情况下将我的网站的根目录redirect到一个子网站。 喜欢

http://www.domain.com/ ---> http://www.domain.com/subsite 

我已经尝试过,但是这匹配所有的URL:

 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_root 

nlu几乎在那里,但is_root ACL是有点closures。

使用path_beg将导致任何和所有的path匹配,当你真的只想redirect与空path的请求。

尝试使用acl is_root path -i /替代,因为只有当path为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 

你可以检查,如果它已经开始子网站,并使用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