Forum Discussion
dgloff_22332
Nimbostratus
Sep 20, 2012switch used for string replacement skipping one case
I have to do a redirect from default.asp and default.aspx in any path, to just the path (with no filename), with a few exceptions. Initially, I had the following iRule, which worked fine:
when ...
Brian_Van_Stone
Nimbostratus
Sep 24, 2012My best guess is that the second to last section is not being skipped but that you are falling through and matching both cases. "http://www.example.com/default.aspx" is first matching "*/default.aspx" and then matching "*/default.asp" overwriting your previous changes to replaceURI. You can either get more specific with the match expressions (which I'm no pro at, haven't done anything beyond simple switches in TCL) or you can wrap the logic on the last case with an if checking to see if replaceURI is null or has value. If null, continue, otherwise do nothing.
Might be worth the "if" approach just to determine if this is the problem and then you can clean up the switch after. You can also take advantage of the fall through to shorten up the first few cases into:
"/accountants/*"
"/businesspartners/*"
"/product/health-insurance/*"
"/helpkb/*" {
return
}
A match on any of them would result in the return statement being executed.
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