Forum Discussion

Anush's avatar
Anush
Icon for Nimbostratus rankNimbostratus
Mar 17, 2016

redirect site using irule

Hi Expert,

 

We have one requirement from out client but I am not sure whether it is even possible or not. looking for your help on this.

 

Sample requirement :

 

https://abc.com/sites/Portal/support/Pages/TechnologySupport.aspx?reqtype=GeneralTech&rt=myPC&sd=aaa&dd=xxx rediect to https://xyz.com/generaltechnical?reqtype=GeneralTech&rt=myPC&sd=aaa&dd=xxx

 

Text in bold is dynamic portion, they want to add it in redirect url accordingly. I know we can append whole URI portion in redirect site but not sure about portion of it.

 

Thanks

 

2 Replies

  • Can do it this way (not tested, but should work):

    when HTTP_REQUEST {
        set sd [findstr [HTTP::query] "sd=" 0 "&"]
        set dd [findstr [HTTP::query] "dd=" 0 "&"]
        
        if { $sd ne "" && $dd ne "" } {
            HTTP::redirect "https://xyz.com/generaltechnical?reqtype=GeneralTech&rt=myPC&$sd&$dd"
        }
    }
    

    Notice that I don't constrain this conditional; that is, I assume you want to redirect any URI that has sd and dd query parameters. If you want to limit it further, that is simple: just add an

    if
    conditional around the entire block that checks for what you need (e.g., HTTP host header, uri-path).