Forum Discussion
shawno_84086
May 30, 2007Nimbostratus
Realtional URI rewrites
I am completely new to irules and I would like some validation, or perhaps a better way to do what I want.
I am deploying a new website that uses a completely new set of URIs. All of the previous...
May 31, 2007
Posted By citizen_elah on 05/31/2007 6:23 AM
I couldn't quite infer whether those mappings are static or dynamically generated, but if they are static, you can easily create a class for that:
class myURImappings {
"abc xyz"
"bcd wxy"
"cde vwx"
"def uvw"
}
Then your rule is quite simple:
when HTTP_REQUEST {
if { [matchclass [string tolower [HTTP::uri]] starts_with $::myURImappings] } {
HTTP::respond 301 Location "http://www.mydomain.com/[findclass [string tolower[HTTP::uri] $::myURImappings " "]"
}
}
That won't quite work because the value of HTTP::uri will always start with a slash. Also, your findclass call is assuming that the URI equals the value in the class, but the originally supplied code used the contains operator.
We don't have measurements for class lists of 10000+ entries, but you'll have to expect that it will have a performance impact (you can't get 10000 string comparisons for free).
If you can supply some real examples of what you are trying to map from/to there might be a way to use some tricks to limit the number of mappings needed. For instance, if you need to map:
/aaa/foo -> /ZZZ/foo
/aaa/bar -> /ZZZ/bar
...
Then you can do some string splitting and just extract the first element of the URI and look that up, then dynamically build the redirect/respond retaining the original trailing section of the URI. But without examples/requirements I don't know if that will work for you.
-Joe
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