CodeShare
Have some code. Share some code.
cancel
Showing results for 
Search instead for 
Did you mean: 
Deb_Allen_18
Historic F5 Account

Problem this snippet solves:

Intercepts pages with HTTP Status Code 301 (Permanent Redirect) & re-writes the Status Code as 302 (Temporary Redirect).

Special handling or an alternate approach may be required to preserve any cookies or other custom headers returned by the server.

Code :

# To redirect to the same location, same protocol:

when HTTP_RESPONSE {
  if { [HTTP::status] == "301" } {
    # respond with 302 using original Location value
    HTTP::respond 302 Location [HTTP::header Location]
  }
}

# To redirect to the same location but change protocol from HTTP to HTTPS:

when HTTP_RESPONSE {
  if { [HTTP::status] == "301" } {
    # respond with 302 using original Location value
    HTTP::respond 302 Location [string map { http:// https:// } [HTTP::header Location]]
  }
}
Version history
Last update:
‎18-Mar-2015 14:53
Updated by:
Contributors