Forum Discussion
redirecting hostname to proper URI path
I was asked to create a redirect whenever a client types this into their browser, omsqa.domain.com redirect it to http://omsqa.tbccorp.com/isccs/isccs/login.do. My irule seems to perform the redirect but the page doesn't load, I get error redirecting occur in firefox. If i use fiddle i can see it perform the 302 redirect. I'm not sure what else to look at. If I remove the irule from the VS, and go directly to the full URL (http://omsqa.tbccorp.com/isccs/isccs/login.do) it works fine. Please help
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::host]] {
"omsqa.tbccorp.com" - {
HTTP::redirect ";
}
}
}
- Robell_Pontes_7
Nimbostratus
Hi there,
try this instead:
when HTTP_REQUEST { if { [HTTP::uri] equals "/"}{ HTTP::uri "/isccs/isccs/login.do" } }
- samstep
Cirrocumulus
Your iRule causes a redirection loop. The "Host" part of "http://omsqa.tbccorp.com/isccs/isccs/login.do"; is the same "omsqa.tbccorp.com" so your iRule will keep redirecting users to the same URL on each request. You need to add an extra check on HTTP::uri eq "/"
- Andy_McGrath
Cumulonimbus
when HTTP_REQUEST { if {[string tolower [HTTP::host]] eq "omsqa.tbccorp.com" && [HTTP::uri] eq "/"} { HTTP::redirect "http://omsqa.tbccorp.com/isccs/isccs/login.do" } }
- Robell_Pontes_7
Nimbostratus
as the previous user mentioned before, you don't need a redirect: the host is the same.
HTTP::uri should do the trick....
- Stanislas_Piro2
Cumulonimbus
rewriting HTTP::uri is not the best solution, mostly when path folder is different.
- Stanislas_Piro2
Cumulonimbus
AMG provided the best solution. I also recommend to use HTTP::path instead of HTTP::uri in condition and to redirect to relative URI / absolute path (beginning with /) instead of absolute URL:
when HTTP_REQUEST { if {[string tolower [HTTP::host]] eq "omsqa.tbccorp.com" && [HTTP::path] eq "/"} { HTTP::redirect "/isccs/isccs/login.do" } }
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com