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...
nitass
Employee
Dec 30, 2014this is just another example.
configuration
[root@ve11a:Active:In Sync] config tmsh list ltm virtual bar
ltm virtual bar {
destination 172.28.24.10:80
ip-protocol tcp
mask 255.255.255.255
pool foo
profiles {
http { }
tcp { }
}
rules {
qux
}
source 0.0.0.0/0
source-address-translation {
type automap
}
vs-index 2
}
[root@ve11a:Active:In Sync] config tmsh list ltm rule qux
ltm rule qux {
when RULE_INIT {
set static::param {receiptLocator originCity firstName lastName}
set static::newparam {ReceiptLocator CityOrigin FirstName LastName}
set static::len [llength $static::param]
}
when HTTP_REQUEST {
if { [HTTP::uri] starts_with "/receiptLocator" } {
set newuri "/"
for {set i 0} {$i < $static::len} {incr i} {
set pvalue [URI::query "?[string trimleft [HTTP::uri] /]" [lindex $static::param $i]]
if { $newuri ne "/" } {
append newuri "&"
}
append newuri "[lindex $static::newparam $i]=$pvalue"
}
HTTP::redirect "http://[HTTP::host]$newuri"
} else {
do nothing
}
}
}
test
[root@ve11a:Active:In Sync] config curl -i "http://172.28.24.10/receiptLocator=ABCDEF&originCity=BOS&firstName=John&lastName=Doe&language=en"
HTTP/1.0 302 Found
Location: http://172.28.24.10/ReceiptLocator=ABCDEF&CityOrigin=BOS&FirstName=John&LastName=Doe
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
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