Forum Discussion
Stephen_Archer_
Jul 03, 2006Historic F5 Account
re-write HTTP Response code 302 to HTTPS
Hi, I hope someone can help.
I have adapted the following code from a previous post:
when HTTP_RESPONSE {
if { [HTTP::status] contains "302"} {
if { [HTTP::header location] contains "http://www.test.com/portal/" } {
set newLoc [string map {http://www.test.com/portal/ https://www.test.com/portal/} [HTTP::header location] ]
HTTP::header replace location "$newLoc"
}
}
}
When a server sends a 302 response, the response includes a location field. A packet capture shows that the loaction field is set to "http://www.test.com/portal/", however I see no log entry and the header is not modified.
All I need to do is to change http to https, and leave the rest of the string intact. Am I going about this the right way?
Hope you can help!
Thank you,
A'
- Colin_Walker_12Historic F5 AccountWell, the first thing I would do is add a log statement to each step of the rule, to make sure that all the different sections are being evaluated as expected.
when HTTP_RESPONSE { if { [HTTP::status] contains "302"} { log local0. "Status code captured : [HTTP::status]" if { [HTTP::header location] contains "http://www.test.com/portal/" } { log local0. "Location header matches : [HTTP::header location" set newLoc [string map {http https} [HTTP::header location] ] log local0. "New string location: $newLoc" HTTP::header replace location "$newLoc" } } }
- Stephen_Archer_Historic F5 AccountColin,
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