Forum Discussion

jvernetti68_163's avatar
jvernetti68_163
Icon for Nimbostratus rankNimbostratus
Apr 09, 2018
Solved

Redirect hostname and uri maintaining uri using LTM traffic policies

Hello, I am using more ltm traffic policies these days and I am wondering if anyone knows how to do a redirect that detects the /uri and redirect that dynamically. For instance if users bookmarked https://whatever.com/abc_123 I want to redirect that to https://www.whatever.com/abc_123. (basically we are redirecting any non www. traffic to www) I was doing this with an ltm traffic policy that said when the hostname included whatever.com redirect to https://www.whatever.com but that strips off the uri...not what our apps folks wanted. We also have hundreds of uri's so its no feasible to do a redirect for every possible uri.

 

Currently I am using the below iRule but I am wondering if there is a way to do this with ltm traffic policy.

 

when HTTP_REQUEST { if { ([HTTP::host] equals "whatever.com") } { HTTP::redirect "https://www.whatever.com[HTTP::uri]" } }

 

  • Hi, yes for sure it is possible. Simply to Redirect to location write:

    tcl:https://www.[HTTP::host][HTTP::uri]
    

    Or more specific:

    tcl:https://www.whatever.com[HTTP::uri]
    

3 Replies

  • Hi, yes for sure it is possible. Simply to Redirect to location write:

    tcl:https://www.[HTTP::host][HTTP::uri]
    

    Or more specific:

    tcl:https://www.whatever.com[HTTP::uri]