Jay_Sawyer_1110
Feb 08, 2008Nimbostratus
Trailing / in uri
Hi all,
I have an iRule using matchlass with a class file that contains the following
"/uri1/us/ http://www.mysite.com/us/foo/info.html",
"/uri2/uk/ http://www.mysite.com/uk/bar/info.html",
"/test/ca http://www.anothersite.com/shop/br/basket/info.html",
...and so on.
here's the iRule:
when HTTP_REQUEST {
set my_uri [string trimright [HTTP::uri] "\/" ]
set my_uri [HTTP::uri]
set idx_starts [matchclass $my_uri equals $::starting_uri]
set idx "[lindex $::starting_uri [expr $idx_starts -1]]"
if { $idx_starts > 0 } {
set mapto [findclass $idx $::redir_map " "]
if { "http://[HTTP::host][HTTP::uri]" equals ${mapto} } {
log local0. "Loop prevention for [HTTP::host][HTTP::uri]."
return
} else {
log local0. "Redirecting [HTTP::uri] to ${mapto}."
HTTP::redirect ${mapto}
return
}
} else {
log local0. "No redirection available for [HTTP::uri]"
}
}
So, my query is this; how can the iRule handle the trailing / whether it is used in the URI or not, how can I keep it a match or make /uri1/us/ equal /uri1/us?
Thanks for the knowlege!