Forum Discussion
vbhagat_122571
Nimbostratus
Sep 06, 2013iRule 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
...
JRahm
Admin
Sep 06, 2013Try something like this:
when HTTP_RESPONSE {
STREAM::disable
set strexp ""
if { [HTTP::header Content-Type] matches_glob "text/*ml" } {
append strexp "@http://user.example.net/images@@"
append strexp "@http://user.example.net/port@@"
}
if { $strexp ne "" } {
STREAM::expression $strexp
STREAM::enable
}
if { [HTTP::header exists "Location"] } {
if { [HTTP::header "Location"] starts_with "http://" } {
HTTP::replace "Location" [string map "http:// https://" [HTTP::header "Location"]]
}
}
}
when STREAM_MATCHED {
switch -glob [string tolower [STREAM::match]] {
"http://user.example.net/images" { STREAM::replace "https://user.example.net/images" }
"http://user.example.net/port" { STREAM::replace "https://user.example.net/port" }
}
}
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