Forum Discussion
Jay_Prasanth_13
Nimbostratus
Oct 14, 2014How to create iRule to forward request depending on context input
For eg. when user type http://abc.com/aa/bb/cc/xx/yy/zz , iRule should redirect to http://abc.com/aa/bb/cc?t1=xx&t2=yy&t3=zz
Explanation of above Example
http://abc.com/aa/bb/cc/xx/yy/zz ...
Hannes_Rapp_162
Nacreous
Oct 14, 2014Try something as follows. If you want to use 302 as a redirect method, make sure you also use the
TCP::close close command after event disable
when HTTP_REQUEST {
if { [HTTP::uri] starts_with "/aa/bb/cc" } {
set PREFIX_STATIC "/aa/bb/cc"
log local0. "Original URI: [HTTP::uri]"
set XX_VAL [ getfield [HTTP::uri] "/" 5]
set YY_VAL [ getfield [HTTP::uri] "/" 6]
set ZZ_VAL [ getfield [HTTP::uri] "/" 7]
log local0. "XX_VAL = $XX_VAL | YY_VAL = $YY_VAL | ZZ_VAL = $ZZ_VAL"
log local0. "Redirect destination: [HTTP::host]$PREFIX_STATIC?t1=$XX_VAL&t2=$YY_VAL&t3=$ZZ_VAL"
HTTP::respond 301 Location "[HTTP::host]$PREFIX_STATIC?t1=$XX_VAL&t2=$YY_VAL&t3=$ZZ_VAL"
event disable
}
}
Oct 14 10:12:08 local/tmm info tmm[15625]: Rule irule_asd-test : Original URI: /aa/bb/cc/f3/f4/f5
Oct 14 10:12:08 local/tmm info tmm[15625]: Rule irule_asd-test : XX_VAL = f3 | YY_VAL = f4 | ZZ_VAL = f5 Oct 14 10:12:08 local/tmm info tmm[15625]: Rule irule_asd-test : Redirect destination: www.abc.com/aa/bb/cc/?t1=f3&t2=f4&t3=f5Hannes_Rapp_162
Nacreous
Oct 28, 2014Keep everything the same, except the 3 lines below. (Untested solution)
set XX_VAL [ getfield [HTTP::uri] "-" 0]
set YY_VAL [ getfield [HTTP::uri] "-" 1]
set ZZ_VAL [ getfield [HTTP::uri] "-" 2]
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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