Forum Discussion
Jan_384807
Nimbostratus
Feb 27, 2019irule based on URI to select pool redirected back to http
Hi,
I need help here.
I'm using the same VS to create a irule to redirect to different server pools based on URI.
The irule which I created redirects back to http which is not what I'm expected.
...
Andy_McGrath
Cumulonimbus
Feb 27, 2019For your iRule, which looks ok but the following is a little improved:
when HTTP_REQUEST {
if {[string tolower [HTTP::host]] starts_with "test.abc.com"}{
if {([string tolower [HTTP::uri]] starts_with "/testing") }{
HTTP::respond 301 Location "https://[getfield [HTTP::host] : 1]/homepage"
} elseif { [string tolower [HTTP::uri]] starts_with "/homepage" }{
pool "poolB"
}
}
}
If your web server is then doing a redirect it maybe using
http protocol instead of https as the server is listening on HTTP. Should be able to change this setting on the web server so the Location in any redirect HTTP response uses https as the protocol or you could write an iRule to change the Location value in any response.
The following iRules is an example of performing this
Location header replacement:
when HTTP_RESPONSE {
if {([HTTP::header exists "Location"]) && ([HTTP::header value "Location"] starts_with "http://test.abc.com"))} {
HTTP::header replace "Location" [string map "http://test.abc.com" "https://test.abc.com" [HTTP::header value "Location"]]
}
}
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
