Rewrite HTTP responses with HTTP status code 301 which is for Permanent Redirect to 302 which is used for Temporary Redirect.
# 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]] } } |
Source: https://devcentral.f5.com/codeshare/rewrite-http-redirect-301-to-302
add rewrite action 301_302 replace HTTP.RES.FULL_HEADER.AFTER_STR(" ").BEFORE_STR("\r\n") '"302 Found"' add rewrite policy 301_302_pol 'HTTP.RES.STATUS.EQ(301)' 301_302_act
Bind Rewrite policy to specific VSERVER or to Global rewrite bind point on response flow. Here we are parsing the HTTP response from backend to find out the Status code “301” and then rewrite it with the action to “302 Found”.