Rewriting Redirects
While best practices for virtualized web applications may indicate that relative self-referencing links and redirects (those which don't include the protocol or the hostname) are preferable to absolu...
Published May 14, 2008
Version 1.0Deb_Allen_18
Historic F5 Account
Joined September 25, 2004
Deb_Allen_18
Historic F5 Account
Joined September 25, 2004
jurgenvdmark_14
May 08, 2014Nimbostratus
I've been looking for a method to change absolute redirects into relative redirects. The following does the trick:
when HTTP_RESPONSE {
if { [HTTP::is_redirect] } {
Replace absolute redirect with relative redirect
HTTP::header replace Location [regsub {https?://[^/]*/} [HTTP::header value location] "/"]
}
}
Basically it looks for every HTTP location starting with "http://" or "https://" and then looks for any character other than "/"/ and replaces it with a single "/"