Forum Discussion
George_72275
Nimbostratus
Jun 08, 2012How 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/events
I would like the 2nd one to stay http://www.abc.com/join/events in the URL bar when the user types it but redirect behind the scenes to http://www.abc.com/join
Is that possible?
Thanks,
George
5 Replies
- Richard__HarlanHistoric F5 AccountThe following should work for you
when HTTP_REQUEST {
if { [HTTP::uri] equals "/join/events" } {
HTTP::uri "/join"
}
} - George_72275
Nimbostratus
Unfortunately that did not work as I receive the following 404 error:
HTTP Status 404 - /join/events/
--------------------------------------------------------------------------------
type Status report
message /join/events/
description The requested resource (/join/events/) is not available. - That's because the iRule is comparing the string "/join/events" and you passed in "/join/events/".
Something like this should workwhen 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 thiswhen 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 - George_72275
Nimbostratus
Many thanks Joe!
The switch statement with the "string tolower" did it. And now I know that much more about iRules. :)
Thanks,
George - George_72275
Nimbostratus
The customer has now changed the requirements.
1) http://www.abc.com/join
2) http://www.abc.com/join/events
They would like the 2nd one to stay http://www.abc.com/join/events in the URL bar when the user types it but redirect behind the scenes to a different server entirely: http://www.xyz.com/join
What is the proper command string to make that work unbenownst to the end user?
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