Forum Discussion
Rob_Morhaime_11
Nimbostratus
Aug 20, 2008Simple iRule not working - is it my "string map" syntax?
This seems like a simple iRule, but when applied I get socket errors. Here's the rule:
when HTTP_RESPONSE {
if { [HTTP::is_redirect] }{
if { [HTTP::header Location] contains "PageMustBeSecure.htm" }{
HTTP::header replace Location "[string map -nocase {"http://" "https://"} [HTTP::header Location]]"
}
}
}
Is it the quotes in my string map? I swear I saw that syntax somewhere, but now I can't find it. The LTM is running 9.1.0.
- Nicolas_Menant
Employee
Hi,when HTTP_RESPONSE { if { [HTTP::is_redirect] }{ if { [HTTP::header "Location"] contains "PageMustBeSecure.htm" }{ HTTP::header replace "Location" [string map -nocase {"http://" "https://"} [HTTP::header "Location"]] } } }
when HTTP_RESPONSE { if { [HTTP::is_redirect] }{ log local0. "is redirect -> [HTTP::header "Location"]" if { [HTTP::header "Location"] contains "PageMustBeSecure.htm" }{ log local0. "redirect contains PageMustBeSecure.htm " HTTP::header replace "Location" [string map -nocase {"http://" "https://"} [HTTP::header "Location"]] log local0. "new redirect is: [HTTP::header "Location"]" } } }
- Rob_Morhaime_11
Nimbostratus
I'll try your suggestions tonight. - Rob_Morhaime_11
Nimbostratus
Well, the logging statements helped. Thank you for that suggestion. Here's the output: - spark_86682Historic F5 AccountIt's sort-of a documentation error. It turns out that the HTTP::is_redirect function framework was in 9.0.0, but some important code was left out. The documentation is often based on the framework, though, which is why it says that 9.0.0 has that command. That's also the reason that you get a runtime error, but not an error when you load the configuration. I'll update the wiki.
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