Redirect 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 { not ([HTTP::uri] starts_with "/context") } {
HTTP::uri /context
pool pool_80
} else {
pool pool_80
}
}
What this essentially does is:
- If the URI starts with /context/ws (eg. http://domain.com/context/ws/index.jsp), then use pool_8080
- If the URI DOES NOT START with /context (eg. http://domain.com/page.jsp), then change URI to /context and use pool_80
- If the URI starts with /context (eg. http://domain.com/context/page.jsp), then forward to a pool_80
Due to a design issue, the application is not able to handle the first time access to the page eg. http://domain.com/context/first.jsp Subsequent accesses (once authenticated) will work. So the first time the user comes in with the URL http://domain.com/context/first.jsp we want to redirect the user to a different URL like http://domain.com/context/login.jsp
How do we trap the first request in the iRule? [HTTP::uri] starts_with "/context/first.jsp" will trap all requests but we just want to trap only the very first one (when the user is not authenticated yet) and then redirect to the login URL. What would be the CONDITION in the iRule below so that it will modify the URI only in the case of the very first request and not subsequent requests?
if { [HTTP::uri] starts_with "/context/first.jsp" AND (___CONDITION___)} {
HTTP::uri /context/login.jsp
pool pool_80
}
Any thoughts would be much appreciated.
Thanks in advance.