4

I would like to redirect the root of my website to a subsite by default. Like

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

I have tried this, but this matches all the URLs anyway:

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
14

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
6
  • 1
    No problem, I find keeping track of all the derivatives of the sampling keywords to get a little bewildering myself, never mind keeping track of the keywords themselves. – GregL Jan 24 '15 at 19:28
  • In my use case, a match is also made for /?someurl. Meaning, it will follow the redirect, which is undesired. – Kevin C Jul 27 '20 at 14:18
  • It’s matching ‘/?someurl’ using the path sampler? – GregL Jul 27 '20 at 14:23
  • I only want the root path to be redirected, meaning domain.com/ So, I use the code you supplied. When configured, I also get redirected when using /another_url, which is undesired. – Kevin C Jul 27 '20 at 14:48
  • But are you using the path, or path_beg sampler? – GregL Jul 27 '20 at 19:40
1

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
3
  • This won't work. I would like to redirect / to /subsite... – Ianthe the Duke of Nukem Jan 20 '15 at 17:02
  • Hope I got it right now – nlu Jan 20 '15 at 17:15
  • This would work only for this subsite, however, it would be a maintenance burden as we add new subsites. Greg's solution is exactly what I needed. Thanks for helping, though. Cheers! – Ianthe the Duke of Nukem Jan 23 '15 at 15:56
0

I had same issue, then i use acl below to resolved my issue.

    acl is_root path_beg -i /
    http-request set-path /subsite if is_root

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.