Forum Discussion
Jan 30, 2007
You can modify the URI with the HTTP::uri command. This should be pretty close to what you want.
when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] starts_with "/abc" } {
HTTP::uri [string map -nocase {"/abc" "/123/bac"} [HTTP::uri]]
}
}
What this does is for all URI's that start with "/abc", it will replace the "/abc" with the string "/123/bac"http://foo.com/abc -> http://foo.com/123/bac
http://foo.com/abc/file.ext -> http://foo.com/123/bac/file.gif
One gotcha to watch out for is that the string map command will replace all occurances of the first string with the second. So this would also happen which may or may not cause you issues.http://foo.com/zzz/abc.ext -> http://foo.com/zzz/123/bac.gif
If that is an issue, then you may want to do something like this using findstr to strip out the initial characters in the URI.
when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] starts_with "/abc" } {
HTTP::uri "/123/bac[findstr [string tolower [HTTP::uri]] "/abc" 4]"
}
}
This one can have some gotchas as well...http://foo.com/abc.gif -> http://foo.com/123/bac.gif
Only you know your web application so you'll have to account for all these subtleties and work around them. But for your initial question, at least one of these should work for you.
-Joe