Forum Discussion
Little_Daemon_1
Nimbostratus
Nov 13, 2013Redirect initial request to a different URL
Guys, I have an iRule that looks like this:
when HTTP_REQUEST {
if { [HTTP::uri] starts_with "/context/ws" } {
pool pool_8080
} elseif ...
Kevin_Stewart
Employee
Nov 14, 2013Let's assume that the request for "/context/first.jsp" is followed by subsequent calls to the same URL, and that all happen within the same TCP session. If that is the case, then Steve's iRule above should fill the requirement. The condition is triggered ONLY if the request is for "/context/first.jsp", AND ONLY if this is the first request in the TCP session.
Otherwise, given the stateless nature of HTTP, you'd probably have to resort to a state mechanism like cookies to prevent further triggering of the condition. Example:
when HTTP_REQUEST {
if { not ( [HTTP::cookie exists STATECOOKIE] ) } {
First time through
set setcookie 1
if { [string tolower [HTTP::uri]] starts_with "/context/first.jsp" } {
HTTP::uri /context/login.jsp
pool pool_80
} else {
your other logic
}
}
}
when HTTP_RESPONSE {
will insert the cookie on first response
if { [info exists setcookie] } {
unset setcookie
HTTP::cookie insert name "STATECOOKIE" value "1" path "/"
}
}
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects