Forum Discussion

Aditya_Mehra's avatar
Nov 20, 2018

Need to modify the uri via irule

Hi,

 

Need help for an iRule

 

condition:When url has both characters .xxx and / , then redirected url should not have / .

 

incoming url : https://a.b.c.com/aaa// abc/def/geh.xxx?Org=123

 

redirected url : https://b.a.c.com/aaa/abc/def/geh.xxx?Org=123

 

also normal url without / should redirect normally a.b.c to b.a.c

 

incoming url : https://a.b.c.com/

 

redirected url : https://b.a.c.com/

 

1 Reply

  • Hi Aditya,

    If using a traffic policy as Philip has suggested, is not an option, you could use the following iRule:

    when HTTP_REQUEST {
        set var1 "xxx"
        set var2 "/"
        set newHost "b.a.c.com"
    
        if {([HTTP::uri] contains $var1) && ([HTTP::uri] contains $var2)} {
            set newUri [string map -nocase [list $var2 ""] [HTTP::uri]]
            HTTP::redirect  https://${newHost}${newUri}
        } elseif {!([HTTP::uri] contains "/")} {
            HTTP::redirect https://$newHost[HTTP::uri]
        }
    }