Forum Discussion
Danielseyoum
Jan 23, 2008Altostratus
Calling another iRule from with in an iRule
I am inspecting the header for cookie and would like to direct the request accordingly. If cookie is not there the landing page will issue the cookie according to the user's choice of department. By the way all the URLs resolve to the same VIP.
The challenge I am facing is to make sure the URIs are valid for the corresponding URL. Meaning I have to allow certain URI only. I have an other iRule using switch. Can I call another iRule for the matching cookie i.e. call HR_iRule for HR cookie? If so how?
Cookie_iRule
when HTTP_REQUEST {
switch [HTTP::cookie Department] {
"SALES" { HTTP::redirect "http://sales.abc.com"}
"HR" { HTTP::redirect "http://hr.abc.com"}
"IT" { HTTP::redirect "http://it.abc.com"}
default{HTTP::redirect "http://www.abc.com}
}
HR_iRule
when HTTP_REQUEST {
switch [string tolower [getfield [HTTP::uri] "/" 2]]
"benefits"{ HTTP::redirect "http://hr.abc.com/portal/Benefits"}
"ethics"{ HTTP::redirect "http://hr.abc.com/portal/Ethics"}
default{HTTP::redirect "http://hr.abc.com/portal}
}
- hooleylistCirrostratusYou can't call one rule from another, but if you add both rules to the VIP, they'll both be evaluated. One thing to be aware of is that you don't want to try to redirect a request multiple times, so make sure that only one of the switch conditions will be true per request.
- DanielseyoumAltostratuswhen the cookie is of HR, I want the HR_iRule to be processed
- hooleylistCirrostratusDoes the HR site, hr.abc.com, resolve to the VIP which you're going to use the cookie rule logic on? If so, once the Department cookie is set, I would expect the client to present the Department cookie on every request and get constantly redirected to hr.abc.com.
- DanielseyoumAltostratusAll the sites resolve to the same VIP. The link that I am looking for is between once the cookie has been identified and start processing the iRule corresponding to the site. Per your recommendation combining the rules I have the following:
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