Forum Discussion
Rule to automatically "follow" an internal redirect?
http://devcentral.f5.com/Tutorials/TechTips/tabid/63/articleType/ArticleView/articleId/220/Rewriting-Redirects.aspx
but is it possible to instead follow the redirect within BigIP (an internal redirect?), so that the HTTP 301/302 does not go back to the browser?
E.g., browser requests www.example.com/foo/bar.html. BigIP load balances this request to either internal1.example.com or internal2.example.com. But, internal1 might respond with a 301 with "Location: http://internal2.example.com/foo/bar.html". The browser cannot see internal1 / internal2.
Thanks, Jamshid
- hoolio
Cirrostratus
Hi Jamshid,http://devcentral.f5.com/wiki/default.aspx/iRules/http__retry One can save a WAN round trip by following a redirect at the LTM and responding to the original client request with the result of the redirect when HTTP_REQUEST { Save the host header value set host [HTTP::host] } when HTTP_RESPONSE { Check if response is a redirect based on the status code if { [HTTP::is_redirect] } { Now generate a GET request to the new location HTTP::retry "GET [HTTP::header location] HTTP/1.1\r\nHost: $host\r\n\r\n" } }
- Michael_Yates
Nimbostratus
Here is an example to capture a 301 and 302 and redirect them.when HTTP_RESPONSE { if { [HTTP::status] == "301" } { HTTP::redirect "http://www.website.com/" } elseif { [HTTP::status] == "302" } { HTTP::redirect "http://[HTTP::host]/index.html" } }
Recent Discussions
Related Content
* 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