Scenario: if url is http://domain or http://domain/web then there should not be a redirect. For anything else, say http://domain/abc or http://domain/xyz, there should be a redirect to http://domain2.
This is what I tried and but it only works for http://domain/web. If the url is http://domain, it still redirects to http://domain2.
acl is_root path -i
acl missing_slash path_reg ^/*/[^/]*$$
acl isweb path_beg /web
http-request set-header X-Location-Path %[capture.req.uri] if !isweb !is_root !missing_slash
http-request replace-header X-Location-Path [^/]+/(.*) \1 if !isweb !is_root !missing_slash
http-request redirect code 301 location https://www.domain2.com%[hdr(X-Location-Path)] if !isweb !is_root !missing_slash