Spence_Faschin1
Mar 15, 2005Nimbostratus
Rewrite a uri (not redirect)
I have a need to rewrite a uri, and make this look transparent to the end user. What I have come up with is this:
when HTTP_REQUEST {
set loop 0
set max [llength $::shorturi]
while {$loop < $max}{
set tmpstr [lindex $::shorturi $loop]
if {[HTTP::uri] starts_with $tmpstr}{
set uri1 {findstr [http_uri] $tmpstr}
set uri2 {regexp -all -inline {$tmpstr::longuri}}
subst {[HTTP::uri] $uri2}
}
}
}
I have to Data Groups - long_uris and short_uris:
short_uris:
someuri1
someuri2
long_uris:
rewrite/someuri1
rewrite/someuri2
the end of the long uri will always match what the short uri is
I have not had a chance to test this yet - still building out the test environment, but it does not kick any errors on the LTM. I am just looking for some input - as I am not a developer (I'm a network guy).
So - to re-iterate - the long term goal is this:
user comes in to http://www.somesite.com/someuri
and the LTM rewrites the uri on the backside to:
http://www.somesite.com/rewrite/someuri (the rewrite portion is much much longer in the real data)
Thanks in advance