Forum Discussion
whootang
Nimbostratus
Nov 03, 2019irule to redirect and rewrite url
Hi guys, I'm playing around with irules and im trying to do some smarts around a base url redirect and then a rewrite on sub folders. So if you hit testdata.com it will redirect you to xyz.com ...
Nov 03, 2019
Hi whootang,
If you use starts_with for "/", second "if" will never work.
when HTTP_REQUEST {
if { [HTTP::uri] equals "/" } {
HTTP::redirect "https://xyz.com/"
}
if { [string tolower [HTTP::uri]] starts_with "/data/" } {
HTTP::redirect "http://abc.com[HTTP::uri]"
}
}Alternative:
when HTTP_REQUEST {
if { [HTTP::host] equals "testdata.com" } {
switch -glob [string tolower [HTTP::uri]] {
"/" { HTTP::redirect "https://xyz.com/" }
"/data/*" { HTTP::redirect "http://abc.com[HTTP::uri]" }
}
}
}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
