trying to redirect a url

I am trying to redirect a URL from site.domain.com to site.domain.com/subsite. I have the F5 configured for SSL off-loading so anything that come in is redirected from http to https. When a user goes to https://site.domain.com I want them to be redirected to https://site.domain.com/newsite. I tried different iRules but none of them seem to work. Has anyone done this before?

Edited to include loop break/fix

Hello Jeff,

On VIP-80 you’ll have the http → https redirect. On VIP-443 you could use the one below. What issues are you running into?

RULE-x.x.x.x-443
when HTTP_REQUEST {
   if { [string tolower [HTTP::host]] equals "site.domain.com" and !([HTTP::uri] starts_with "/subsite") } {
      set respond value to 301 or 302 as preferred
      HTTP::respond 302 Location "https://site.domain.com/subsite"
}
}

Edited to include loop break/fix

Hello Jeff,

On VIP-80 you’ll have the http → https redirect. On VIP-443 you could use the one below. What issues are you running into?

RULE-x.x.x.x-443
when HTTP_REQUEST {
   if { [string tolower [HTTP::host]] equals "site.domain.com" and !([HTTP::uri] starts_with "/subsite") } {
      set respond value to 301 or 302 as preferred
      HTTP::respond 302 Location "https://site.domain.com/subsite"
}
}

One clarification. You are doing SSL off-loading by applying a client ssl profile on the 443 VIP, correct?

One clarification. You are doing SSL off-loading by applying a client ssl profile on the 443 VIP, correct?

Hi Jeff, I think you are trying to redirect based on a uri

when HTTP_REQUEST {
  if { [HTTP::uri] == "/" } {
  HTTP::redirect "https://[HTTP::host]/newsite" 
  }
}

Thanks, Sekhar

i think you also have to include (check) uri or path in the if-condition. otherwise, it is going to be loop because it redirects to the same fqdn.

i think you also have to include (check) uri or path in the if-condition. otherwise, it is going to be loop because it redirects to the same fqdn.

Thank you for catching that N. Would the below break the redirect loop appropriately? when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals “site.domain.com” and !([HTTP::uri] starts_with “/subsite”)} { set respond value to 301 or 302 as preferred HTTP::respond 302 Location “https://site.domain.com/subsite” } }

Thank you for catching that N. Would the below break the redirect loop appropriately? when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals “site.domain.com” and !([HTTP::uri] starts_with “/subsite”)} { set respond value to 301 or 302 as preferred HTTP::respond 302 Location “https://site.domain.com/subsite” } }

yes, i think so.

yes, i think so.