Forum Discussion
George_72275
Jun 08, 2012Nimbostratus
How to mask URL
Hi there,
I'm new to iRules and trying to come up with a solution here and hoping someone can help. I have two URLs:
1) http://www.abc.com/join
2) http://www.abc.com/join/eve...
Jun 08, 2012
That's because the iRule is comparing the string "/join/events" and you passed in "/join/events/".
Something like this should work
when HTTP_REQUEST {
if { [HTTP::uri] equals "/join/events/" } {
HTTP::uri "/join"
}
}
But, that would ONLY match a url of "/join/events/". "/join/events", "/Join/Events/", etc would not match.
You could also use a "starts_with" to compare like this
when HTTP_REQUEST {
if { [HTTP::uri] starts_with "/join/events" } {
HTTP::uri "/join"
}
}
That would match "/join/events" and "/join/events/" but it would also match on "/join/eventsFOOBAR" or anything else after events in the URI.
If you want to have more options in your comparisons, I'd use a switch statement with the "string tolower" on the URI.
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] {
"/join/events" -
"/join/events/" {
HTTP::uri "/join"
}
}
}
Lots of options, it really depends on your app logic how complex you want to go with the comparison.
-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