Forum Discussion
Pirlo
Nimbostratus
Dec 30, 2014URI inspect - Rewrite - Redirect
DevGods
I am trying to inspect URI and Insert into a newly formatted redirect. I am trying to use the URI Interrogation code to dump the params then formulate the redirect.
If I read the co...
StephanManthey
Nacreous
Dec 30, 2014You can try the following code, please:
when HTTP_REQUEST {
if {[HTTP::query] ne "" && !([HTTP::query] starts_with "ReceiptLocator") } {
set namevals [split [HTTP::query] "&"]
log local0. "[HTTP::query]; number of params: <[llength ${namevals}]>"
for {set i 0} {$i < [llength ${namevals}]} {incr i} {
set param [split [lindex ${namevals} $i] "="]
log local0. "current parameter: <$param>, <${i}> of <[llength ${namevals}]>"
log local0. "param_name: <[lindex $param 0]>, param_value <[lindex $param 1]>"
switch [string tolower [lindex $param 0]] {
"receiptlocator" { set ReceiptLocator [lindex $param 1] }
"origincity" { set CityOrigin [lindex $param 1] }
"firstname" { set FirstName [lindex $param 1]}
"lastname" {set LastName [lindex $param 1]}
}
}
if { [info exists ReceiptLocator] && [info exists CityOrigin] && [info exists FirstName] && [info exists LastName] } {
HTTP::redirect "HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::path]?ReceiptLocator=${ReceiptLocator}&CityOrigin=${CityOrigin}&FirstName=${FirstName}&LastName={LastName}"
} else {
log local0. "missing parameters"
}
} else {
log local0. "no query data or query already in expected format"
}
}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