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 ";
}
}
}
Hi there,
try this instead:
when HTTP_REQUEST {
if { [HTTP::uri] equals "/"}{
HTTP::uri "/isccs/isccs/login.do"
}
}
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 “/”
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"
}
}
as the previous user mentioned before, you don’t need a redirect: the host is the same.
HTTP::uri should do the trick…
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"
}
}
rewriting HTTP::uri is not the best solution, mostly when path folder is different.
If server answers with relative path links in content, browser can request wrong URI next.