Forum Discussion
Andy_McGrath
Feb 27, 2019Cumulonimbus
For 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"]]
}
}