Forum Discussion
Jay_Sawyer_1110
Nimbostratus
Feb 08, 2008Trailing / 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!
- hoolio
Cirrostratus
I edited my earlier post to include the requirement to add the first field of the class without the trailing slash. Is that an option? If so, the trimright on the requested URI should work with only a single class entry per URI.
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