vbhagat_122571
Sep 06, 2013Nimbostratus
iRule to replace http with https for specific URLs
All,
I am pretty new to F5s and am trying to get a iRule together to replace some of the URLs.
For example:
-
Replace http://user.example.net/images with https://user.example.net/images
-
Replace http://user.example.net/port with https://user.example.net/port
-
But do not change the following URL: http://user.example.net/jwp
I tried the following iRule, but it did not seem to work.
when HTTP_REQUEST {
Disable the stream filter by default
STREAM::disable
} when HTTP_RESPONSE {
if {[HTTP::header value Content-Type] contains "text"}{
set find_url1 "http://user.example.net/images"
set replace_url1 "https://user.example.net/images"
set find_url2 "http://user.example.net/port"
set replace_url2 "https://user.example.net/port"
STREAM::expression "@$find_url1@$replace_url1@ @$find_url2@$replace_url2@"
STREAM::enable
}
else {
STREAM::disable}
}
Any inputs will be appreciated.
Thanks!