Forum Discussion
brownie6969_121
May 31, 2012Nimbostratus
redirect irule
our old application url that pointed to the F5 vip was mybicrt.company.com. The new code is mybicrt.company.com/analytics. i created the following that achieves that part of it when HTTP_REQUE...
Michael_Yates
Jun 01, 2012Nimbostratus
OK. Try this...
I shouldn't have built upon what had been provided. The first "/" event needs to be handled....the "/" - will pass it to the next event which is supposed to inject the "/analytics"...so either remove it or point it to where it should be redirected to.
For some reason it wasn't capturing the URI::basename, so rather than building another switch event I just added the trailing "*/saw.dll*" to make it absolute....this could cause problems if anything else on the Virtual Server that uses "/saw.dll" and doesn't need to go to the "/analytics" directory.
This will capture it anywhere in the URL and inject the "/analytics"....it will also (in the First iRule) log the Original HTTP::uri. Then add a second iRule and put the code below in it...then make sure that this iRule is BELOW the first iRule when applied to the Virtual Server (you could use iRule Priorities, but I'm sticking to the topic). This will log the modified HTTP::uri value in the LTM log so that you can verifiy that it is working properly.
First iRule:
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::path]] {
"/" { HTTP::respond 301 Location "http://www.google.com" }
"*/saw.dll*" {
HTTP::uri "/analytics[HTTP::uri]"
log local0. "Saw Event: URI - [HTTP::uri]"
}
}
}
Second iRule for proof that the first is working:
when HTTP_REQUEST {
log local0. "Second iRule HTTP::uri Value: [HTTP::uri]"
}
If it works properly you should see this in your LTM Log:
Jun 1 16:31:46 local/tmm1 info tmm1[30732]: Rule Z.iRule.Development : Saw Event: URI - /saw.dll?Dashboard&PortlPath/shared/Executive/_portal/Executive
Jun 1 16:31:46 local/tmm1 info tmm1[30732]: Rule Z.iRule.Development.2 : Second iRule HTTP::uri Value: /analytics/saw.dll?Dashboard&PortlPath/shared/Executive/_portal/Executive
If your curious about the second iRule for verification you can read this thread: Log Not Showing Modified URI
Hope this helps and fixes it 🙂
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