Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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
share|improve this question

2 Answers 2

up vote 2 down vote accepted

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
share|improve this answer
    
Thank you! I feel dumb missing this out in the manual. –  Ianthe Jan 23 at 15:49
    
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. –  Greg Linton 2 days ago

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
share|improve this answer
    
This won't work. I would like to redirect / to /subsite... –  Ianthe Jan 20 at 17:02
    
Hope I got it right now –  nlu Jan 20 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 Jan 23 at 15:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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