Forum Discussion
SSell
Altostratus
Sep 18, 2015iRule to redirect to new url, but retain path after first location
I have been tasked with creating an irule to redirect a url to a new server. However the existing server will still have other urls still working on it. We need to retain everything in the URL afte...
Brad_Parker_139
Nacreous
Sep 23, 2015For a permanent redirect you would use this to do a 301:
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] equals "www.abc.com" and [string tolower [HTTP::uri]] starts_with "/app/" } {
HTTP::respond 301 noserver Location "https://app.def.com/[string map {/app/ /} [string tolower [HTTP::uri]]]"
}
}
- SSellSep 23, 2015
Altostratus
Awesome, thank you. - SSellSep 23, 2015
Altostratus
We don't have anyway to test this until actual implementation. I was going to leave the question open until we implement and test which is scheduled for next Tuesday. Thanks for your help - Brad_Parker_139Sep 23, 2015
Nacreous
You probably want to add string tolower to prevent case mis-match compares. I update above. - SSellSep 23, 2015
Altostratus
Thank you, I will add that. We setup a test F5 to play with. It's not a like for like comparison, but using wireshark we were able to see that it worked. We just had to make one small adjustment. I needed to remove the '/' at the end of the https://app.def.com/ when it mapped /app/ to / it made the url https://app.def.com// I will add the string tolower and test that as well. Thanks for your help - SSellSep 29, 2015
Altostratus
Worked flawlessly. Thank you
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