Forum Discussion
Domai_23823
Nimbostratus
Aug 22, 2018iRule URI replace help
Hello All - I need help to fix the below iRule
Requirement is when the user types in https://apple.api.com/e/apple/console/ the uri /e/apple/ should be replaced by /console so its going to be https...
youssef1
Cumulonimbus
Aug 22, 2018Hi Domai,
I understand your problem. If you not put / after console at the end of th uri, it's not working. I advise you to rewrite your uri in order to add "/" at the end of uri if it's not present.
Please try this Irule, it will fix your problem
when HTTP_REQUEST {
log local0. "Incoming URI = [HTTP::uri]"
if { [string tolower [HTTP::uri]] starts_with "/e/apple/" } {
if { [string tolower [HTTP::uri]] contains "/console/" } {
set uri [string map [ list "/e/apple/" "/" "/console" "/console/" ] [HTTP::uri]]
} else {
set uri [string map -nocase {"/e/apple/" "/"} [HTTP::uri]]
}
log local0. "New URI = $uri"
HTTP::uri $uri
virtual apple.api_vs_4001
log local0. "Host header is [HTTP::host]"
}
}
Keep me in touch if it working for your.
Regards
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
