Forum Discussion
SK74_347537
Nimbostratus
Mar 15, 2018Replacing the protocol from http to https for certain domain
I am trying to replace the protocol of the Location from http to https for certain domains(url) with iRules but getting error with it.
when HTTP_RESPONSE {
if { ( [HTTP::header exists Location...
oguzy
Cirrostratus
Mar 15, 2018Hi SK74,
class match filter should be in brackets like this.
when HTTP_RESPONSE {
if { ( [HTTP::header exists Location] ) and ( [HTTP::header Location] contains "http://" ) and ( [ class match [HTTP::header Location] contains ssl-domain-data-group ] ) } {
HTTP::header replace [string map -nocase {"http://" "https://"} [HTTP::header Location]]
}
}
Also you can try the below one:
when HTTP_RESPONSE {
if { [HTTP::header exists Location] } {
set location_info [HTTP::header Location]
if { ( $location_info contains "http://" ) and ( [class match $location_info contains ssl-domain-data-group ] ) } {
HTTP::header replace [string map -nocase {"http://" "https://"} $location_info]]
}
}
}
- SK74_347537Mar 23, 2018
Nimbostratus
Problem solved! Thanks for the help, really appreciate it. Need to add "Location" before replace to correctly modify the HTTP header.
when HTTP_RESPONSE { if { ( [HTTP::header exists Location] ) and ( [HTTP::header Location] contains "http://" ) and ( [ class match [HTTP::header Location] contains ssl-domain-data-group ] ) } { HTTP::header Location replace [string map -nocase {"http://" "https://"} [HTTP::header 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
